Check External IP From Linux Command Line

There are a few different ways to check a system’s external IP address from the Linux command line. Check out some of the methods below to retrieve your public IP address using Linux commands.

Using dig, curl, and wget commands to check external IP address in Linux

Retrieve External IP Address in Command Line

Method 1. Use the dig command to see your IP address from different name servers, such as opendns.com or Google’s name server.

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

Or with Google’s name server:

$ dig TXT +short o-o.myaddr.l.google.com @ns1.google.com

Method 2. We can also use the curl command and third party websites to view our external IP address. icanhazip.com will show both the IPv4 and IPv6 addresses.

To view IPv4 address:

$ curl -4 icanhazip.com

To view IPv6 address:

$ curl -6 icanhazip.com

Method 3. We can also use the wget command and third party websites to view the external IP address. Once again, we will use icanhazip.com to show both the IPv4 and IPv6 addresses.

To view IPv4 address:

$ wget -4 -qO - icanhazip.com

To view IPv6 address:

$ wget -6 -qO - icanhazip.com

Method 4. There are a bunch of other websites that can be used to view your external IP address. Here’s a few of them that you can try. If you have any more to contibute, or want to report one that no longer works, feel free to leave a comment below.

$ curl ifconfig.me
$ wget -qO - ifconfig.me
$ curl api.ipify.org
$ wget -qO - api.ipify.org
$ curl ipecho.net/plain
$ wget -qO - ipecho.net/plain
$ curl ipinfo.io/ip
$ wget -qO - ipinfo.io/ip

Leave a Comment

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