I've successfully tried all these methods (got from other posts/questions) to get internet IP in Ubuntu but...
curl ipecho.net
curl ifconfig.me
curl ipecho.net/plain
curl ipinfo.io/ip
pi@raspberrypi:~ $ -Command here (any of 4 before curls)-
< html>< /html> pi@raspberrypi:~ $ (in the same line)

curl -s checkip.dyndns.org|sed -e 's/.Current IP Address: //' -e 's/<.$//'
Output (html code):
var hardwarePlatform = navigator.platform.toLowerCase();
var agent = navigator.userAgent.toLowerCase();

wget -q -O - checkip.dyndns.org|sed -e 's/.Current IP Address: //' -e 's/<.$//'
Output: nothing

wget -qO- http://ipecho.net/plain ; echo
Ootput (html code):
< ! DOCTYPE html> < html xmlns="http://www.w3.org/1999/xhtml">
< head>
< meta name="csrf_token" content="/gRClgpBjNDPhyORm0miqmAlQJfxVmiQ"/>

EDIT: First thing I think is if those outputs are not IP numbers there would be a problem with internet connection (not related with RPi - off topic as stated by some users). Sorry.

  • 1
    Please bring some structure into your text and sample outputs. – user13700 Jan 5 '18 at 22:27
  • 1
    I thought I could clarify your question by editing it, but your formatting is all over the place, so I didn't. If you can actually make your question readable, then we might be able to point you in the right direction. – Darth Vader Jan 7 '18 at 18:38
  • Even if you made this very clear (you are trying to get your external IP, i.e., the one used by your LAN router) and use impeccable formatting, this is off-topic here as it really has nothing to do with the Raspberry Pi. You might try our larger sibling site, Super User, or Unix & Linux – goldilocks Jan 8 '18 at 15:20
  • That´s something I don't know. It never happened to me until in RPi and it has gone after some reboots. It was strange to have an output "<html></html>" from those 4 curl command options – dstonek Jan 8 '18 at 19:26
  • Now it comes again. After changing connection to another network, curl ipinfo.io/ip outputs <html></html>. After some reboots, DC reconnections, network changes I am getting the same output – dstonek Jan 8 '18 at 20:46

Your question isn't completely clear, but you can use hostname to show only the IP address of you machine like so:

pi@raspberry:~ $ hostname -I

"hostname -I" returns the local, LAN, IP address.

"curl https://api.ipify.org/" returns the remote, WAN, IP address and nothing else. It's 15 of less characters. e.g. ""

|improve this answer|||||
  • Sorry, I added in the post that it is the internet IP what I mean. I get internal IP with ifconfig – dstonek Jan 8 '18 at 13:42
  • I couldn't try your suggestion "curl api.ipify.org" because I read it after problem gone and all methods are working fine now. Thanxs – dstonek Jan 8 '18 at 13:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.