Hardcore Linux

Anything about Ubuntu, Centos, openSuSe and Fedora

Getting WAN IP on console or shell script.

There are few other guide in getting your current WAN IP on Linux console or fetching it within a shell script. But this one works for me.

1. To get the current WAN IP:

$> echo "$(wget http://automation.whatismyip.com/n09230945.asp -O - -o /dev/null)"

2. For LAN IP address/es:

$> ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'

 

 

About these ads

One response to “Getting WAN IP on console or shell script.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 341 other followers

%d bloggers like this: