wireguard-install icon indicating copy to clipboard operation
wireguard-install copied to clipboard

CentOS 7: incorrect detection of public server IP

Open dvershinin opened this issue 3 years ago • 3 comments

The installer suggests the following:

IPv4 or IPv6 public address: 188.188.188.188 peer 10.0.0.1

For a newbie like me, this may appear correct (partially includes the public IP), but includes extraneous "peer 10.0.0.1" which gives problems later on!

ip -4 addr output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    inet 188.188.188.188 peer 10.0.0.1/32 brd 188.188.188.188 scope global eth0
       valid_lft forever preferred_lft forever
    inet 188.188.188.188/32 scope global eth0
       valid_lft forever preferred_lft forever

In the outputs above, I obfuscated the real public IP with 188.188.188.188, for obvious reasons.

dvershinin avatar Dec 11 '20 20:12 dvershinin

Moreover it gets public IP as IP address from ethernet interface, but server can be behind NAT already then its eth0 IP4 address is 10.0.0.1 or sort of. I guess that more reliable way to get it by asking some public service like we have here : grep -m 1 -oE '^[0-9]{1,3}(\.[0-9]{1,3}){3}$' <<< "$(wget -T 10 -t 1 -4qO- "http://ip1.dynupdate.no-ip.com/" || curl -m 10 -4Ls "http://ip1.dynupdate.no-ip.com/")"

V-ctor avatar Aug 22 '22 08:08 V-ctor

curl is most universally available. I think no need for wget at all. Just curl ifconfig.me does it for me.

dvershinin avatar Aug 22 '22 09:08 dvershinin

I don't insist with wget. Yes curl ifconfig.me works for me too.

V-ctor avatar Aug 22 '22 10:08 V-ctor

Closing as CentOS 7 won't be supported any more

angristan avatar Jan 22 '23 10:01 angristan