• About
  • Privacy Policy
  • Contact us
  • Submit a story
Linux-News Linux news from the Blogosphere
  • Article
  • Howto
  • News
  • Opinion
  • Review
  • RSS Feed
  • Twitter
  • Facebook

Quickly Get an External IP Address from the Command Line

By
News
– February 12, 2015Posted in: Article, Howto, Submitted
Most of the machines in various institutes and organizations are set up behind a NAT router and thus, they are allocated with a private IP address, either manually or by the DHCP server.To the outer world, your (public) IP address is same as that of the NAT router. There are many techniques with which you can detect the public IP address of your machine. This mini-article will be helpful to you to know the public IP address of your NAT router using Terminal.
    You would be taking help of an external web server in order to detect your public IP address. So, make sure that your system is connected to internet. As you are dependent on that particular web server, you need to have curl installed in our system.

If you don’t have curl installed, just enter following command:

For Ubuntu, Linux Mint or other Debian based systems:

sudo apt-get install curl


For Fedora, CentOS or other RHEL based systems:

sudo yum install curl

Once this is done, you can use any of the following commands listed below to get your public IP address. You can run them in terminal or you can also use them in bash scripts. Here is the list:

curl ident.me
curl ifconfig.me
curl tnx.nl/ip
curl icanhazip.com
curl ipecho.net/plain
curl ip.appspot.com
curl whatsmyip.akamai.com

First posted on http://www.yourownlinux.com/

Alternative DIG

As alternative you could use dig with OpenDNS as resolver:

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

Perhaps alias it in your bashrc so it’s easy to remember

alias wanip='dig +short myip.opendns.com @resolver1.opendns.com'

Responds with a plain ip address:

$ wanip
80.100.192.168

Article sponsored by Lowhosting.com
Tags: bash, curl, dig, ip, public

About News

No Comments

Start the ball rolling by posting a comment on this article!

Leave a Reply Cancel reply

Your email address will not be published.

  • Suggested Sites
    http://linuxaria.com everything about Linux http://linuxaria.com everything about Linux
  • Curated topic
  • Recent Posts
    • Unleash the Power of PDF Security: A Guide to Content Preparation Progress Turn Off
    • Unlock the World of Coins with the World Coin Catalog Krause 47th Edition PDF
    • Master the Alphabet with Printable Traceable Worksheets [PDF Download]
    • Master PDF Merging with “I Love PDF Merge”: The Ultimate Guide
    • How to Insert a PDF into PowerPoint: A Guide to Seamless Integration
    • Ace Your CNA Exam: Free Practice Test with Answers PDF!
    • Unleash the Power of Complex Variables: A Comprehensive Guide to Brown and Churchill’s Masterpiece
    • Out of the Abyss PDF: Embark on an Epic Underdark Adventure
    • Uncover Hidden Corruption: The Ultimate Guide to “Dan Bongino Follow the Money PDF”
    • Catholic Daily Readings 2023 PDF: Your Guide to Spiritual Growth
  • Ranking

About Arras WordPress Theme

All site content, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.