Get your public IP via shell

To get your public IP you can use websites like www.whatismypublicip.com/ or just google for it (http://lmgtfy.com/?q=public+ip)

Get your public IP via shell
Get your public IP via shell

But you can also get your public IP via the following Linux shell  command (the smart way :-D):

$> curl ifconfig.me/all

This gives you an output like that:

ip_addr: 31.18.198.134
remote_host: ip123456.dynamic.kabel-deutschland.de
user_agent: curl/7.35.0
port: 47745
lang: 
connection: 
keep_alive: 
encoding: 
mime: */*
charset: 
via: 
forwarded: 

Or for IP address only output:

$> curl ifconfig.me/ip

Example output:

31.32.33.242

To install curl you have to run:

$> sudo apt-get install curl

Under CentOs you can call:

$> /sbin/ifconfig

 

One thought on “Get your public IP via shell

Leave a Reply

Your email address will not be published.

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.