-2

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
Output:
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();
Etcetera

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"/>
Etcetera

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.

dstonek
  • 156
  • 1
  • 1
  • 14

1 Answers1

2

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
151.101.193.69

"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. "16.218.186.74"

falling cat
  • 161
  • 2