Linux Network Troubleshooting

Linux Network Troubleshooting

Click the blue text to follow us

Network issues typically manifest as the following problems:

▪ Website inaccessible

▪ Application response is slow

▪ Intermittent connection drops

▪ Data transfer timeouts

Focus: How to quickly locate the problem?

Linux Network Troubleshooting

Diagnostic Process

Step 1: Basic Connectivity Check (ping command)

# Check local loopback ping 127.0.0.1
# Check gateway connectivity ping $(ip route | grep default | awk '{print $3}')
# Check DNS resolution ping baidu.com ping 8.8.8.8

Diagnostic Key Points:

🔹 Packet loss rate exceeding 5% needs attention

🔹 Latency exceeding 100ms may indicate network congestion

🔹 Unable to ping the gateway indicates a local network configuration issue

Step 2: Route Path Analysis (traceroute)

# Linux system traceroute google.com
# If traceroute is unavailable, use mtr mtr --report --report-cycles 10 google.com

Output Interpretation Tips:

traceroute to google.com (142.250.191.14), 30 hops max, 60 byte packets
1  192.168.1.1 (192.168.1.1)  1.234 ms  1.123 ms  1.456 ms
2  10.0.0.1 (10.0.0.1)  15.678 ms  16.789 ms  17.234 ms
3  * * *  (Request timed out)
4  8.8.8.8 (8.8.8.8)  45.123 ms  44.567 ms  43.890 ms

🔹 The third hop shows an asterisk: this may indicate a firewall blocking ICMP or device failure

🔹 Sudden increase in latency: this node may be congested

🔹 Continuous timeouts at a hop: focus on troubleshooting that network device

Step 3: Port Connectivity Testing

# Check specific ports telnet target-host 80
nc -zv target-host 443
# Batch port scan nmap -p 80,443,22,3306 target-host

Step 4: DNS Resolution Verification

# View DNS configuration cat /etc/resolv.conf
# Manual DNS query nslookup example.com
dig example.com
# View domain resolution process dig +trace example.com

Linux Network Troubleshooting

Diagnostic Tips

1. Network Interface Status Check

# Check network interface status ip addr show
ip link show
# Check network statistics cat /proc/net/dev
ss -tuln  # View listening ports

2. Firewall Rule Investigation

# iptables rule check iptables -L -n -v
# View connection tracking cat /proc/net/nf_conntrack | grep target-ip

3. Route Table Analysis

# View route table ip route show
route -n
# Add temporary route for testing ip route add target-network via gateway-ip

Linux Network Troubleshooting

Efficiency Improvement Tools

1. Automated Diagnostic Script

#!/bin/bash
# network-check.sh
TARGET=${1:-"8.8.8.8"}
echo "=== Network Diagnostic Report ==="
echo "Target Address: $TARGET"
echo "Check Time: $(date)"
echo
echo "1. Basic Connectivity Test:"
ping -c 4 $TARGET
echo -e "\n2. Route Path Analysis:"
traceroute $TARGET
echo -e "\n3. DNS Resolution Test:"
snlookup $TARGET
echo -e "\n4. Local Network Configuration:"
ip addr show | grep -A 2 "state UP"

2. Monitoring Alert Setup

# Use watch for continuous monitoring
watch -n 5 'ping -c 1 critical-server && echo "OK" || echo "FAILED"'
# Combine with zabbix or prometheus for automated monitoring

Linux Network Troubleshooting

Fault Prevention Strategies

1. Network Health Check List

🔹 Regularly check the status of network devices

🔹 Monitor bandwidth usage

🔹 Check DNS resolution performance

🔹 Validate the availability of backup links

🔹 Update network device firmware

2. Automated Monitoring Script

#!/bin/bash
# daily-network-check.sh
HOSTS=("8.8.8.8" "114.114.114.114" "your-critical-server.com")
LOG_FILE="/var/log/network-health.log"
for host in "${HOSTS[@]}"; do
    if ping -c 3 $host > /dev/null 2>&1; then
        echo "$(date): $host - OK" >> $LOG_FILE
    else
        echo "$(date): $host - FAILED" >> $LOG_FILE
        # Send alert email or SMS
        echo "$host is unreachable" | mail -s "Network Alert" [email protected]
    fi
done

Linux Network Troubleshooting

Conclusion

Network troubleshooting is one of the core skills of operations and maintenance engineers.

Through a standardized diagnostic process:

ping → traceroute → port testing → DNS verification → in-depth analysis

Following this process, you can quickly locate most network issues.

Linux Network Troubleshooting

Copry Enterprise IT Academy

Nanjing Copry Information Technology Co., Ltd. has long focused on promoting the digital construction and development of government and enterprises, providing customers with specialized services including: digital training, IT operation and maintenance services, information security services, business intelligence services, OA application services, and human resources outsourcing. After years of development, Copry has formed a business service model centered on the Nanjing company, with additional branches in Hangzhou and Shanghai, covering East China and radiating nationwide, serving over 5000 customers across various industries including telecommunications, finance, electricity, petrochemicals, tobacco, taxation, public security, social security, and finance, gaining widespread customer recognition!

The Copry Enterprise IT Academy was founded in 2002 and is affiliated with Nanjing Copry Information Technology Co., Ltd. It is dedicated to providing digital professional talent training service solutions for government and enterprise clients, helping clients build and cultivate a sustainable professional talent pipeline. The company has a team of over a hundred expert instructors composed of industry veterans and certified trainers from manufacturers, providing over a hundred digital series courses in various professional directions such as networking, mainframes, software development, large databases, middleware, virtualization, information security, cloud computing, big data, IT management, and IT applications, centered around digital empowerment and the products and technologies of globally renowned IT manufacturers and mainstream domestic innovation ecosystem manufacturers.

Based on the increasingly stratified and diversified digital transformation needs of clients, the Copry Enterprise IT Academy focuses on the pain points of enterprise digital transformation, driving business through digitalization, innovating business through digitalization, and empowering business through digitalization, designing reasonable and effective digital professional talent training programs through specialized communication, consulting, and assessment, emphasizing the relevance, practicality, and efficiency of the courses, relying on a team of digital expert instructors to provide high-quality and efficient training services, helping clients achieve best practices in digital transformation!

Corporate Mission:

Create value for employees, create value for customers, create value for society, and strive to promote the progress of the whole society!

Corporate Vision:

To become a first-class provider of enterprise-level digital talent training solutions in China!

Linux Network Troubleshooting

Campus Address:

—— Nanjing Campus

23rd Floor, Building A, Changfa Center, No. 300 Zhongshan East Road, Nanjing

—— Hangzhou Campus

6th Floor, Building 2, Dongfangmao Commercial Center, Gongshu District, Hangzhou

—— Shanghai Campus

4th Floor, Building 2, No. 33 Leshan Road, Xuhui District, Shanghai

National Service Hotline: 025-87787966

Academy Website: www.china-esp.com

Linux Network TroubleshootingLinux Network TroubleshootingLinux Network Troubleshooting

Leave a Comment