How to Test Network Connectivity in Linux (ping, traceroute, dig, nslookup)

Understanding Network Connectivity in Linux

Network connectivity testing is the process of verifying whether your Linux system can reach other hosts on the network or the internet. It helps identify where communication breaks down — whether it’s your local setup, the DNS server, or the remote host itself.

In Linux, you can easily test connectivity using a few built-in tools like ping, traceroute, dig, and nslookup. These tools help troubleshoot DNS issues, routing problems, or unreachable hosts.

Essential Linux Commands for Testing Network Connectivity

These commands help you diagnose network issues, check DNS resolution, and ensure your system can communicate with other hosts effectively.

1. ping

The ping command checks if a host is reachable and measures how long it takes to receive a response.
It’s the first command most administrators use for basic connectivity checks.

Example:

ping -c 4 google.com

What it does:
Sends 4 ICMP echo requests to google.com and shows response time for each packet.

Why it’s useful:
Quickly confirms if a domain or IP is reachable and how fast the connection is.

2. traceroute

The traceroute command shows the path packets take to reach a destination.
It helps identify where a network connection slows down or fails.

Install (if not available):

sudo apt install traceroute -y

Example:

traceroute google.com

Why it’s useful:
Reveals the number of hops (routers) and pinpoint where the connection is dropping.

3. dig

The dig (Domain Information Groper) command queries DNS servers to retrieve information about domain names.
It’s ideal for checking if a domain resolves to the correct IP address.

Install:

sudo apt install dnsutils -y

Example:

dig google.com

To get only the IP address:

dig +short google.com

Why it’s useful:
Checks if DNS resolution is working properly and retrieves detailed DNS records like A, MX, or NS.

4. nslookup

The nslookup command performs quick DNS lookups similar to dig, but with simpler output.

Example:
nslookup google.com

Why it’s useful:

Quickly checks if a domain resolves and which DNS server is responding.
You can also test using a specific DNS server:

nslookup google.com 1.1.1.1

Why These Tools Matter

  • ping – Confirms host availability and network latency.
  • traceroute – Detects routing problems and delays across the network.
  • dig – Troubleshoots DNS resolution issues in detail.
  • nslookup – Performs quick and simple DNS checks.

Using these tools together gives you a complete view of your network connectivity and helps diagnose most connection issues efficiently.

Purchase a KVM VPS – Choose a KVM VPS plan from us that suits your requirements.

KVM SSD Plans – https://crowncloud.net/ssd_kvm.php
NVMe SSD KVM VPS Plans –  https://crowncloud.net/nvme_kvm.php
AMD Ryzen SSD KVM VPS – https://crowncloud.net/ssd_amd_ryzen_kvm.php
Intel i9 12900K SSD KVM VPS Plans – https://crowncloud.net/ssd_intel_i9_kvm.php

(Visited 6 times, 6 visits today)