Howto get your own WAN IP address

I found this today in one of the forums. I thought that it is quite handy. If you want to know your public IP address you can use this command in bash or other shells.

dig +short myip.opendns.com @resolver1.opendns.com

Just add it as an alias in your .bashrc file.

alias myWANIP=’dig +short myip.opendns.com \@resolver1.opendns.com’

[root@centos6 ~]# myWANIP
92.236.31.198

About Juergen Caris

I am 54yo, MSc(Dist) and BSc in Computer Science, German and working as a Senior Server Engineer for the NHS Lothian. I am responsible for the patient management system, called TrakCare. I am a UNIX/Linux guy, working in this sector for more than 20 years now. I am also interested in robotics, microprocessors, system monitoring, Home automation and programming.
This entry was posted in Bash, Linux. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>