Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

How can I get my external IP address using the Command Line?

share|improve this question
add comment

marked as duplicate by Seth Mar 14 at 20:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

6 Answers

These will get the local IPs:


or for shorter output:

ifconfig | grep inet


ip addr show

This should get the external IP

wget http://smart-ip.net/myip -O - -q ; echo

Don't have to install anything then smiley

N.B. If you don't mind to installing curl, this as well:

curl http://smart-ip.net/myip
share|improve this answer
add comment

Easier and no need to install anything :

  • wget http://ipecho.net/plain -O - -q ; echo
share|improve this answer
Nice hat... :-) –  Wilf Dec 17 '13 at 18:09
@wilf I agree it's awesome, but where is that hat from?!!? –  RPi Awesomeness Dec 17 '13 at 19:11
Don't know how I did but I have it :P –  yilmi Dec 17 '13 at 19:17
@RPiAwesomeness - Dunno, apparently it's secret :-) - winterbash2013.stackexchange.com/chuck-yeager –  Wilf Dec 17 '13 at 20:29
@wilf I've gathered that. Everyone seems to not know :( –  RPi Awesomeness Dec 18 '13 at 2:17
add comment

The shortest one I know is

ip a

It's the same as ip address show with less typing.
Because we all love efficiency ;)

share|improve this answer
+1 for the golfed solution –  AJMansfield Dec 18 '13 at 1:31
If you're behind a router, this will not provide you public ip of router. –  yilmi Dec 29 '13 at 9:30
add comment

Simple , Open your terminal( CTRL+ALT+T) and type as

  curl ifconfig.me

Just wait for 5 - 10 Sec then you can see your IP.

make sure that curl installed ,If curl not installed , then please Install it with

sudo apt-get install curl
share|improve this answer
You may want to mention that this will get the external IP - good idea anyway. –  Wilf Dec 17 '13 at 20:32
add comment

This will return your Modem's IP in a single line:

wget -q -O - checkip.dyndns.org | sed -e 's/[^[:digit:]|.]//g'

If you wish this data in a file simply do the next:

wget -q -O - checkip.dyndns.org | sed -e 's/[^[:digit:]|.]//g' > ipfile.txt

Good luck!

share|improve this answer
add comment

There is no predefined command that can do this task.
You can use http://whatismyip.org/

share|improve this answer
add comment

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