Linux Networking Commands

Linux provides many command-line tools for inspecting network interfaces, testing connectivity, viewing routes, checking open ports, and troubleshooting network problems. These commands are essential for Linux administrators and developers.

Why Learn Linux Networking Commands?

Network issues can affect applications, servers, and cloud workloads. Linux networking commands help identify whether a problem is related to the interface, routing, DNS, connectivity, or a listening service.

TEXT
Check Interface → Test Connectivity → Inspect Route → Check DNS → Inspect Ports → Troubleshoot

Using the ip Command

The ip command is one of the primary tools for managing and inspecting network interfaces, addresses, routes, and other networking information.

BASH
ip addr
ip link
ip route

Checking Network Interfaces

The ip addr command displays network interfaces and their assigned IP addresses.

BASH
ip addr show
ip link show

Testing Connectivity with ping

The ping command sends ICMP echo requests to test whether a host is reachable and to measure round-trip response time.

BASH
ping example.com
ping -c 4 8.8.8.8

Checking Network Routes

The routing table determines where network traffic is sent. The ip route command displays the routes configured on the system.

BASH
ip route
ip route get 8.8.8.8

Checking Open Ports with ss

The ss command displays sockets and listening network services. It is commonly used to identify which services are listening on specific ports.

BASH
ss -tuln
ss -tulpn

Testing DNS Resolution

DNS translates domain names into IP addresses. Tools such as dig and nslookup can be used to inspect DNS resolution.

BASH
dig example.com
nslookup example.com

Using curl for Network Testing

curl can be used to test HTTP and HTTPS connections, inspect responses, and verify whether a web service is reachable.

BASH
curl -I https://example.com
curl -v https://example.com

Linux Networking Command Table

CommandPurposeExample
ipInspect interfaces and routesip addr
pingTest connectivityping example.com
ssInspect sockets and portsss -tuln
digQuery DNSdig example.com
curlTest HTTP servicescurl -I https://example.com
tracerouteInspect network pathtraceroute example.com

Example Troubleshooting Scenario

TEXT
Website Not Loading → Check Interface → Test IP Connectivity → Check DNS → Inspect Route → Test Port → Check Service

Checking Network Configuration

  • Check IP addresses with ip addr
  • Check routes with ip route
  • Check DNS configuration
  • Check listening ports with ss
  • Test remote connectivity with ping or curl

Common Linux Networking Problems

  • Incorrect IP configuration
  • Missing default route
  • DNS resolution failure
  • Blocked network ports
  • Service not listening
  • Firewall configuration issues

Common Mistakes to Avoid

  • Assuming DNS is the problem without testing IP connectivity
  • Checking the wrong network interface
  • Ignoring the routing table
  • Forgetting to check whether a service is listening
  • Running network changes without understanding their impact

Advanced Linux Networking Concepts

  • Network namespaces
  • Virtual network interfaces
  • Bridges
  • Routing tables
  • iptables and nftables
  • TCP and UDP sockets
  • Network troubleshooting with packet capture

Practice Exercises

  • Display all network interfaces
  • Find your system's IP address
  • Test connectivity to a remote host
  • Display the default route
  • Find listening TCP and UDP ports
  • Perform a DNS lookup
  • Test an HTTP endpoint with curl

Conclusion

Linux networking commands provide powerful tools for understanding and troubleshooting network connectivity. Learning ip, ping, ss, dig, curl, and routing commands gives administrators a strong foundation for diagnosing common network problems.

Note: Note: Run networking commands carefully on production systems, especially commands that modify interfaces, routes, or firewall rules.