MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
June
Sun Mon Tue Wed Thu Fri Sat
       
9
 
2017
Months
Jun


Fri, Jun 09, 2017 11:01 pm

Obtaining public IP address from a command line interface

One way to determine the public IP address for a system, i.e., the IP address that systems on the Internet will see for the system when you connect to those external systems, from a command-line interface (CLI) on a Linux or Mac OS X/macOS system is to use the dig command dig +short myip.opendns.com @resolver1.opendns.com. E.g.:

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

Alternatively, you can use an nslookup command as shown below:

$ nslookup myip.opendns.com resolver1.opendns.com
Server:		resolver1.opendns.com
Address:	208.67.222.222#53

Non-authoritative answer:
Name:	myip.opendns.com
Address: 137.103.94.167

$

The nslookup method will work on Microsoft Windows systems as well as OS X/macOS and Linux sysems.

c:\Users\Public\>nslookup myip.opendns.com resolver1.opendns.com
Server:  resolver1.opendns.com
Address:  208.67.222.222

Non-authoritative answer:
Name:    myip.opendns.com
Address:  137.103.94.167


c:\Users\Public\>

Both commands submit a Domain Name System (DNS) query to the DNS server resolver1.opendns.com, a name server maintained by OpenDNS. When you look up the fully qualified domain name (FQDN) myip.opendns.com, the OpenDNS server will return the IP address of the system from which the DNS query originated, i.e., the system on which you ran the dig or nslookup command.

[/network/dns] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo