« Back to Networking: Frequently Asked Questions

How to see the IP address of your internet connection

How to see the IP address of your internet connection from the command line?

Use the dig command and query the myip.opendns.com hostname to see the IP address of your internet connection that performed the DNS query.

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

There are multiple ways to find out your internet IP address from the command line. One way is using the dig command.

Using dig

With dig we can query the hostname myip.opendns.com. To prevent any intermediate DNS resolver to send an incorrect answer, use the source system.

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

Using curl

Some external websites also provide the IP address. If there is no proxy between you and the related server, it can also provide your IP address.

curl ifconfig.me

Relevant commands in this article

Like to learn more about the commands that were used in this article? Have a look, for some there is also a cheat sheet available.

Other questions related to Networking

    Related articles

    Like to learn more? Here is a list of articles within the same category or having similar tags.

    Feedback

    Small picture of Michael Boelen

    This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

    Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

    Mastodon icon