4
0
I have access to a headless Debian server which I would like to learn the external IP address. How can I do that? The server is connected to the Internet.
4
0
I have access to a headless Debian server which I would like to learn the external IP address. How can I do that? The server is connected to the Internet.
2
The following will do the trick.
curl checkip.dyndns.org
7
This will do just fine and no need for grep
:
curl icanhazip.com
You can use curl's -4
and -6
command line switches to explicitly request for a v4 or v6 IP address, the default being IPv6 if your network supports it.
1Why should we trust a site like icanhazip? – MariusMatutiae – 2013-09-28T16:07:39.423
1Interesting point - why should we trust (or not trust) any site? – Scot – 2013-09-28T19:31:02.103
interesting point: fudge, fudge, and more fudge. – MariusMatutiae – 2013-09-28T20:04:39.610
3
You can use http://ipecho.net/plain with lynx
, wget
, or curl
. I'm sure there are many, many others you could use it with too...
lynx
lynx --dump ipecho.net/plain
lynx
to download the page and display it on stdout. curl
curl ipecho.net/plain
wget
wget -q -O - ipecho.net/plain
wget
where to write the output to. The dash after it means stdout.
You can also use http://www.whatismyipaddress.com easily enough with lynx
.
lynx --dump whatismyipaddress.com | grep "Your IP"
...and if you're really desperate, you're sure to be able to do it this rediculously complex way!
exec 3<>/dev/tcp/ipecho.net/80
echo -en "GET /plain HTTP/1.1\nHOST: ipecho.net\n\n" >&3
cat <&3
Output looks something like this...
HTTP/1.1 200 OK
Date: Sat, 28 Sep 2013 14:59:07 GMT
Server: Apache
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-cache
Pragma: no-cache
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html
d
76.177.248.16
0
lol I googled
checkip.dyndns.org
and there's a ton of malware warnings. Not saying it is for sure... but... – Kolob Canyon – 2018-09-06T03:47:55.860@KolobCanyon Then you should be Googling again, this time just the site name: you will see many sites stating something like Once again, chekcip.dns.org is not malicious. Just try it for yourself. Besides, if you try the above command, you will see that the reply is simply: <html><head><title>Current IP Check</title></head><body>Current IP Address: 11.22.33.44</body></html>. It's hard to imagine where to hide malware in this. Mostly, this is slander from less reputable sites like icanhazip, trying to intercept a fraction of the traffic, that's all. – MariusMatutiae – 2018-09-06T05:02:13.417
Fair enough. I ended up using
ifconfig.me
but yeah... it probably isnt malware. I'm just uncomfortable withcurl
orwget
to a website I'm not sure I can trust. Seems like it would be easy to inject malicious code into the terminal – Kolob Canyon – 2018-09-06T15:49:22.143