The 10 Useful Networking Commands You Should Know

Learn about useful networking commands that are pre-installed on your computer and will help you know everything about a website.

Published in: What is my IP address

Make a curl or wget request to the and it prints the public IP address of your computer. You can also connect to Akamai’s domain get your external IP address.

What is my Private IP address

ifconfig en0 | grep inet

Your computer has a private IP address that only work within the local network. For older Macs with a wired Ethernet port, use en0 for Ethernet interface or en1 for the WiFi interface. The networksetup -listnetworkserviceorder command will print a list all network interfaces available on your machine.

Find the Location of IP address


The free ‘ip2c’ service resolves an IP address to the country.

Or use the ‘ipapi’ service to get more details of an IP address including the city name, timezone and even the latitude and longitude associated with an IP address.


Check DNS Records

The dig command will help you query for any type of DNS records for a domain from the command line.

1. Find the IP address of a website

dig +short

2. Find the Mail Server of Domain

The Mail Exchange (MX) records specify the incoming mail servers that used for delivering email messages sent to your domain name.

host -t MX

3. Print all DNS Records of a Domain

Get a list of all DNS records of a domain including TXT records, MX records and name servers. The name servers handle queries regarding the location of the domain’s website, email and other services.

dig +nocmd any +noall +answer

Who is hosting a website?

Use the dig command to find the IP address of a website and then use the same dig command to perform a reverse lookup to find the host of that IP address.

For instance, this command will print the IP address of the Netflix website:

dig +short A | tail -1

Use that IP address in the next command to get the hostname:

dig +nocmd -x +noall +answer

Find the owner of the website

Use the built-in whois command to reveal important information about any web domain including the date when it was first registered, the contact details of the website owner, the expiration date of the domain, the name of the domain registrar and so on.


You can also query the domain registration details on a specific registrar’s server with the -h flag. For instance, the next command performs a whois lookup on a website using the WHOIS server of Google Domains.

whois -h

Test Network Connectivity with Ping

The ping command helps you test if a remote host is reachable and whether your machine can connect to it properly.

ping -c 5 -i 2

The above command pings the host 5 time and there’s a 2 second wait between pings.

Where’s the fault?

If your Internet connection is working but you are unable to reach a website, there could be an issue with an intermediate router that the packets have to pass through to reach the server.

The traceroute commands prints the network path from your local computer to the website that the traffic must pass through and this information can be useful for diagnosing connectivity issues.


Also see: Essential Tools for Developers

Leave a Reply

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