Linux Networking Commands: ping, ip, netstat, ss, and traceroute

Linux provides a rich collection of networking tools for diagnosing connectivity issues, configuring interfaces, and monitoring network traffic.

Whether you are a Linux beginner, system administrator, or DevOps engineer, mastering networking commands is an essential skill.

This guide covers the most commonly used Linux networking commands with practical examples and explanations.

Concept Overview

Networking commands help administrators verify connectivity, inspect IP addresses, monitor ports, troubleshoot DNS issues, and analyze network routes.

These utilities are available on most Linux distributions and are frequently used in server administration and troubleshooting.

Networking Basics

1. IP Address – Identifies a device on a network.

2. Network Interface – Hardware or virtual device used for network communication.

3. Port – Communication endpoint used by applications.

4. DNS – Resolves domain names into IP addresses.

5. Gateway – Connects one network to another.

Checking Connectivity with ping

The ping command sends ICMP echo requests to verify whether a remote host is reachable.

BASH
ping google.com
ping -c 4 8.8.8.8

Explanation

The -c option specifies how many packets should be sent before stopping.

A successful response confirms basic network connectivity and displays packet loss and response times.

Viewing Network Interfaces with ip

The ip command replaces older networking tools like ifconfig and provides extensive networking information.

BASH
ip addr
ip link
ip route
ip neigh

Explanation

ip addr displays IP addresses assigned to network interfaces.

ip link shows network interface status.

ip route displays the routing table.

ip neigh shows the ARP neighbor table.

Monitoring Network Connections

Linux provides commands to inspect active connections and listening ports.

Using netstat

BASH
netstat -tuln
netstat -rn

netstat displays listening ports, routing tables, and active network connections.

Using ss

BASH
ss -tuln
ss -tunap

The ss command is faster than netstat and provides detailed information about TCP, UDP, and Unix socket connections.

Tracing Network Routes

The traceroute command identifies the path packets take between your system and a remote host.

BASH
traceroute google.com

Explanation

Each hop between the source and destination is displayed along with response times.

This command is useful for identifying routing delays and network bottlenecks.

Additional Useful Networking Commands

Several other commands are commonly used for Linux network troubleshooting.

BASH
hostname
hostname -I
nslookup google.com
dig google.com
curl https://example.com
wget https://example.com

Explanation

hostname displays the system hostname.

hostname -I displays assigned IP addresses.

nslookup and dig perform DNS queries.

curl and wget retrieve resources from web servers for testing connectivity.

Example Troubleshooting Workflow

Verify internet connectivity using ping.

Check your IP configuration using ip addr.

Inspect the routing table using ip route.

View listening ports using ss -tuln.

Trace the network path using traceroute.

Verify DNS resolution using nslookup or dig.

Applications

Troubleshooting network connectivity problems.

Managing Linux servers and cloud infrastructure.

Monitoring open ports and network services.

Diagnosing DNS and routing issues.

Performing security audits and server maintenance.

Advantages

Provides detailed information about network configuration.

Helps identify connectivity and routing problems quickly.

Essential for Linux system administration and DevOps.

Limitations

Some commands require administrative privileges.

Certain utilities such as netstat or traceroute may not be installed by default on every Linux distribution.

Network troubleshooting often requires combining multiple commands to identify the root cause.

Best Practices

Prefer the ip command instead of deprecated tools like ifconfig.

Use ss instead of netstat on modern Linux systems whenever possible.

Verify both network connectivity and DNS resolution during troubleshooting.

Monitor open ports regularly to improve system security.

Mastering Linux networking commands is an essential skill for Linux administrators, DevOps engineers, cybersecurity professionals, and cloud engineers.