Linux Networking Commands
Linux provides powerful tools for monitoring, diagnosing, and troubleshooting network issues. Below, we explore essential commands and how to use them effectively.
Checking Connectivity
- Usage: Test connectivity to a host.
ping google.com - Sends ICMP packets to the destination and measures the response time.
-
Use
Ctrl+Cto stop the command. -
Troubleshooting Example:
- If
pingfails, it could indicate: - Network connectivity issues.
- DNS resolution problems.
- If
- Usage: Trace the path packets take to a destination.
traceroute google.com -
Identifies where delays or failures occur in the route.
-
Troubleshooting Example:
- Use
tracerouteto pinpoint where packets are getting dropped.
- Use
Viewing Network Configuration
- Usage: Display network interfaces and IP addresses.
ip addr -
Look for
inetto find assigned IPs. -
Troubleshooting Example:
- If no IP is assigned, check your DHCP configuration or static IP settings.
- Usage: Similar to
ip addrbut older.ifconfig
Examining Network Connections
- Usage: Display network connections, routing tables, and more.
netstat -an
- Usage: Faster, modern replacement for
netstat.-Troubleshooting Example:ss -tuln- Use
ssto identify open ports and active connections.
- Use
Querying DNS
- Usage: Query DNS for IP addresses.
nslookup google.com
- Usage: Advanced DNS query tool.
dig google.com - Troubleshooting Example:
- Use
nslookupordigto verify DNS resolution. - If DNS fails, check your
/etc/resolv.conffile or DNS server configuration.
- Use