Troubleshooting Linux Networking
Networking issues in Linux can be complex and frustrating, but with the right tools and approach, most problems can be resolved quickly. This guide covers common networking issues and provides step-by-step troubleshooting methods to help you get your Linux system back online.
Common Networking Issues
Network Interface Not Detected
Symptoms:
- The network interface is missing or not recognized by the system.
- Commands like
ifconfig
orip a
do not list the expected network interface.
Troubleshooting Steps:
- Check Hardware: Ensure the network cable is connected and the network card is properly seated.
- List Network Interfaces: Use the following command to check if the network interface is detected by the system:
- Reboot and Check dmesg Logs: Reboot the system and check
dmesg
logs for any hardware detection errors: - Install/Update Drivers: Install or update the network drivers. On Debian/Ubuntu:
IP Address Not Assigned
Symptoms:
- The network interface is detected, but no IP address is assigned.
- Unable to connect to the network or access the internet.
Troubleshooting Steps:
- Check DHCP Configuration: Ensure your system is configured to obtain an IP address via DHCP:
- Static IP Configuration: If using a static IP, verify the settings in
/etc/network/interfaces
(Debian/Ubuntu) or/etc/sysconfig/network-scripts/ifcfg-<interface>
(RHEL/CentOS). - Restart Network Services: Restart networking services to apply the configuration:
DNS Issues
Symptoms:
- Unable to resolve domain names, but can connect to IP addresses directly.
Troubleshooting Steps:
- Check DNS Configuration: Verify the DNS servers listed in
/etc/resolv.conf
: - Test DNS Resolution: Use
dig
ornslookup
to test DNS resolution: - Flush DNS Cache: Clear the DNS cache if using a caching service like
systemd-resolved
:
Routing Issues
Symptoms:
- Unable to reach certain networks or the internet, despite having an IP address.
- Misconfigured or missing routes.
Troubleshooting Steps:
- Check Routing Table: Display the current routing table with:
- Add or Modify Routes: If routes are missing, add them manually:
- Restart Network Services: After making changes, restart the networking service.
Firewall Blocking Traffic
Symptoms:
- Network connections fail despite correct configurations.
- Specific ports or services are unreachable.
Troubleshooting Steps:
- Check Firewall Rules: Review the active firewall rules with
iptables
ornftables
: - Allow Necessary Ports: Add rules to allow traffic on required ports:
- Disable Firewall Temporarily: To rule out firewall issues, disable it temporarily:
Go deeper with basic IPTables or advanced IPTables.
Network Performance Issues
Symptoms:
- Slow network speeds or intermittent connectivity.
- High latency or packet loss.
Troubleshooting Steps:
- Test Network Speed: Use
iperf
orspeedtest-cli
to measure network performance. - Check for Packet Loss: Use
ping
to check for packet loss: - Inspect Network Interfaces: Check for errors on network interfaces:
- Adjust MTU Settings: If packet fragmentation is an issue, adjust the MTU size:
Best Practices for Network Troubleshooting
Use Logging
Always check logs (/var/log/syslog
, dmesg
) for clues.
Keep Backups
Backup configuration files before making changes.
Isolate the Issue
Try to determine if the issue is local, network-wide, or related to external services.