Search This Blog

Monday, March 30, 2009

script to get the external IP address

When a machine sits behind a router, it has two IP addresses. One internal (assigned by the router), one external (assigned by the ISP). To find the external IP address of the machine, I use the following script called ip.
$cat ip
#! /bin/sh

# get the external IP address of the machine
# Author : Kamraju Kusumanchi
# Date : Mon Mar 30 00:08:11 EDT 2009

curl www.whatismyip.org
echo ""
On my machine, I have
$curl --version
curl 7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/0.6.5 libssh2/0.18
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz
Execution
$which ip
/home/rajulocal/bin/ip

$ip
141.153.242.115

5 comments:

Sunil said...

Seems you are back in action after long hibernation.

Kamaraju Kusumanchi said...

Hey Sunil! Nice to see that you follow my blog. I didn't know ...

sri said...

It's nice article.
We can find our ip address and the geolocation of an ip address by using this ip-details.It's used to know the internet speed also.

m11.in said...

Thanks for writing this blog. it's great blog.
...................................

Kamaraju Kusumanchi said...

Thanks for your kind words! That made my day!

Followers