Skip to main content

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.

What is my IP address? Who is the host of this website? Which mail service is this domain using? There exist web tools that can uncover these details but this sort of research can also be done using the command line on your computer.

Network Commands

Let’s explore a few essential networking commands that will help you know everything about a website from the terminal itself.

What is my IP address

curl https://checkip.amazonaws.com

Make a curl or wget request to the checkip.amazonaws.com and it prints the public IP address of your computer. You can also connect to Akamai’s whatismyip.akamai.com 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

curl https://ip2c.org/?ip=8.8.8.8

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.

curl https://ipapi.co/8.8.8.8/json

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 www.labnol.org

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 labnol.org

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 amazon.com 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 netflix.com A | tail -1

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

dig +nocmd -x 52.11.104.17 +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.

whois dictation.io

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 whois.google.com reverse.photos

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 labnol.org

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.

traceroute labnol.org

Comments

Popular posts from this blog

Let People Quickly Save your Events on their Calendars

Create Add to Calendar links for emails and websites and let users quickly save your events on their own Google Calendar, Outlook or Yahoo Calendar. You are organizing an online event - maybe a meeting on Zoom or a training session hosted on Google Meet - and you would like the attendees to add the event to their own calendars. Once added to their calendar, the event will act as an automatic reminder and attendees will get a notification when the conference is about to start. There are two way to go about this: You can create a new meeting in your online calendar (Google, Outlook or any other calendar) and add the individual attendees as guests so the event automatically gets added to their calendar as well. You can include an “Add to Calendar” link or button in your email messages,  forms  and website pages. Anyone can click the link to quickly save your event on to their calendars - see  live demo . Create Add to Calendar Links for Emails and Websites The  Add to C...

How to Determine if your Mobile Phone will work in Another Country?

You are planning to buy a cell phone from an online shopping site of another country but are not too sure if that phone will work with the mobile networks of your country. Or consider a slightly different scenario. You are travelling but how do you determine if your existing cellphone will be compatible with carriers of the foreign country? Will that Cell Phone Work in my Country? Well, there are basically two factors that may help you determine if a mobile phone will work with cellular operators of another country or not. Here they are: 1. GSM and CDMA are the two most prevalent standards in the mobile world. As a first step, determine the technology (GSM or CDMA) used by the mobile carrier of the foreign country where you are planning to use your phone. Wikipedia has dedicated sections - see pages for  India ,  Europe  and  Asia Pacific  countries - that list the standards used by various carriers of a particular country. If that carrier is on G...

How to Email Spreadsheets Automatically on a Recurring Schedule

Introducing  Email Spreadsheets , a Google Sheets add-on that lets you automate the reporting of spreadsheet data and dashboards by email. If you are an office worker who has been emailing spreadsheets to colleagues manually, this add-on will save you a ton of time. And because it runs on the Google Cloud, your spreadsheet reports will be delivered even while you are offline or on vacation. With Email Spreadsheets, you can schedule reports and it will automatically send them by email on a recurring schedule. You can email entire workbooks, specific sheets inside a workbook or even range of cells. Watch the  video   tutorial  to get started. Email Google Sheets Automatically Go to the Google add-on store and install  Email Google Sheets . Next, open any Google Spreadsheet in your Google Drive, go to the Add-ons menu inside the sheet, choose Email Spreadsheets from the dropdown and then choose Rules to create your first scheduled email report. You are presented wi...