1. 首页 > Linux教程 > 正文

Linux教程FG092-基础网络连通性测试与故障排查

本文档风哥主要介绍基础网络连通性测试与故障排查,包括网络连通性测试的概念、常用网络测试工具、故障排查方法、常见问题处理等内容,参考RHEL 10官方文档,适合系统管理员在生产环境中使用。更多视频教程www.fgedu.net.cn

Part01-基础概念与理论知识

1.1 网络连通性测试的概念

网络连通性测试是指通过发送网络数据包来检测网络设备之间是否能够正常通信的过程。网络连通性测试是网络故障排查的基础,能够快速定位网络问题。

网络连通性测试的层次:

  • 物理层:网线、光纤、接口状态
  • 数据链路层:MAC地址、ARP表
  • 网络层:IP地址、路由表
  • 传输层:TCP/UDP端口
  • 应用层:HTTP、DNS等服务

1.2 网络协议基础

常用的网络协议:

  • ICMP:Internet控制消息协议,用于ping和traceroute
  • TCP:传输控制协议,面向连接的可靠传输
  • UDP:用户数据报协议,无连接的不可靠传输
  • HTTP:超文本传输协议,Web服务
  • DNS:域名系统,域名解析

1.3 故障排查方法论

网络故障排查方法论:

  • 分层排查:从物理层到应用层逐层排查
  • 分段排查:从本地到远程分段测试
  • 对比排查:对比正常和异常环境的差异
  • 日志分析:分析系统日志和网络日志
  • 工具辅助:使用专业工具进行诊断
风哥提示:网络故障排查需要系统性的方法,建议按照分层排查的原则,从底层到高层逐层测试,快速定位问题。学习交流加群风哥微信: itpux-com

Part02-生产环境规划与建议

2.1 网络监控规划

网络监控规划建议:

# 网络监控规划
# 监控指标
– 网络连通性:ping测试
– 网络延迟:ping延迟、traceroute延迟
– 网络丢包:ping丢包率
– 端口可用性:telnet/nc端口测试
– 网络带宽:iftop、nload
– 网络连接:netstat、ss

# 监控频率
– 关键服务:每1-5分钟
– 重要服务:每10-30分钟
– 一般服务:每1-2小时
– 备份服务:每天1-2次

# 监控范围
– 内网监控:局域网内服务器
– 外网监控:互联网服务
– 跨网段监控:不同网段间连通性
– 跨地域监控:不同地域间连通性

2.2 工具选择策略

网络测试工具选择策略:

# 工具选择策略
# 连通性测试
– ping:ICMP连通性测试
– fping:批量ping测试
– hping3:自定义数据包测试

# 路由追踪
– traceroute:路由路径追踪
– tracepath:简化版traceroute
– mtr:结合ping和traceroute

# 端口测试
– telnet:TCP端口测试
– nc:netcat,多功能网络工具
– nmap:端口扫描工具

# 网络监控
– iftop:实时网络流量监控
– nload:网络负载监控
– sar:历史网络数据统计

2.3 告警机制配置

网络告警机制配置建议:

  • 告警阈值:设置合理的告警阈值
  • 告警级别:区分警告、严重、紧急
  • 告警渠道:邮件、短信、即时通讯
  • 告警频率:避免告警风暴
  • 告警恢复:问题解决后发送恢复通知
生产环境建议:建议使用专业的网络监控系统(如Zabbix、Prometheus)进行网络监控,配置合理的告警机制,及时发现网络问题。更多学习教程公众号风哥教程itpux_com

Part03-生产环境项目实施方案

3.1 使用ping测试连通性

3.1.1 基础ping测试

# 1. 测试本地回环地址
# ping -c 4 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.012 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.011 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.010 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.011 ms

— 127.0.0.1 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 0.010/0.011/0.012/0.000 ms

# 2. 测试网关地址
# ping -c 4 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.456 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.458 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.455 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.457 ms

— 192.168.1.1 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 0.455/0.456/0.458/0.001 ms

# 3. 测试外网地址
# ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=116 time=12.345 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=116 time=12.346 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=116 time=12.344 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=116 time=12.345 ms

— 8.8.8.8 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 12.344/12.345/12.346/0.000 ms

# 4. 测试域名解析
# ping -c 4 www.baidu.com
PING www.a.shifen.com (110.242.68.4) 56(84) bytes of data.
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=1 ttl=54 time=5.678 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=2 ttl=54 time=5.679 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=3 ttl=54 time=5.677 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=4 ttl=54 time=5.678 ms

— www.a.shifen.com ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 5.677/5.678/5.679/0.000 ms

3.1.2 高级ping测试

# 1. 指定ping包大小
# ping -c 4 -s 1024 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 1024(1052) bytes of data.
1032 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.789 ms
1032 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.791 ms
1032 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.788 ms
1032 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.790 ms

— 192.168.1.1 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 0.788/0.789/0.791/0.001 ms

# 2. 指定ping间隔时间
# ping -c 4 -i 0.5 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.456 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.458 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.455 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.457 ms

— 192.168.1.1 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 1502ms
rtt min/avg/max/mdev = 0.455/0.456/0.458/0.001 ms

# 3. 持续ping测试
# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.456 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.458 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.455 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.457 ms
^C
— 192.168.1.1 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 0.455/0.456/0.458/0.001 ms

# 4. 只显示ping统计信息
# ping -c 4 -q 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.

— 192.168.1.1 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 0.455/0.456/0.458/0.001 ms

3.2 使用traceroute追踪路由

3.2.1 基础traceroute测试

# 1. 追踪到网关的路由
# traceroute 192.168.1.1
traceroute to 192.168.1.1 (192.168.1.1), 30 hops max, 60 byte packets
1 192.168.1.1 (192.168.1.1) 0.456 ms 0.458 ms 0.455 ms

# 2. 追踪到外网的路由
# traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
1 192.168.1.1 (192.168.1.1) 0.456 ms 0.458 ms 0.455 ms
2 10.0.0.1 (10.0.0.1) 2.345 ms 2.346 ms 2.344 ms
3 202.96.128.86 (202.96.128.86) 5.678 ms 5.679 ms 5.677 ms
4 202.96.128.1 (202.96.128.1) 6.789 ms 6.790 ms 6.788 ms
5 8.8.8.8 (8.8.8.8) 12.345 ms 12.346 ms 12.344 ms

# 3. 使用ICMP协议追踪
# traceroute -I 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
1 192.168.1.1 (192.168.1.1) 0.456 ms 0.458 ms 0.455 ms
2 10.0.0.1 (10.0.0.1) 2.345 ms 2.346 ms 2.344 ms
3 202.96.128.86 (202.96.128.86) 5.678 ms 5.679 ms 5.677 ms
4 202.96.128.1 (202.96.128.1) 6.789 ms 6.790 ms 6.788 ms
5 8.8.8.8 (8.8.8.8) 12.345 ms 12.346 ms 12.344 ms

# 4. 指定最大跳数
# traceroute -m 10 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 10 hops max, 60 byte packets
1 192.168.1.1 (192.168.1.1) 0.456 ms 0.458 ms 0.455 ms
2 10.0.0.1 (10.0.0.1) 2.345 ms 2.346 ms 2.344 ms
3 202.96.128.86 (202.96.128.86) 5.678 ms 5.679 ms 5.677 ms
4 202.96.128.1 (202.96.128.1) 6.789 ms 6.790 ms 6.788 ms
5 8.8.8.8 (8.8.8.8) 12.345 ms 12.346 ms 12.344 ms

3.3 使用telnet/nc测试端口

3.3.1 使用telnet测试端口

# 1. 测试SSH端口(22)
# telnet 192.168.1.100 22
Trying 192.168.1.100…
Connected to 192.168.1.100.
Escape character is ‘^]’.
SSH-2.0-OpenSSH_9.0
^]
telnet> quit
Connection closed.

# 2. 测试HTTP端口(80)
# telnet 192.168.1.100 80
Trying 192.168.1.100…
Connected to 192.168.1.100.
Escape character is ‘^]’.
GET / HTTP/1.1
Host: 192.168.1.100

HTTP/1.1 200 OK
Date: Thu, 02 Apr 2026 02:00:00 GMT
Server: nginx/1.24.0
Content-Type: text/html
Content-Length: 612
Last-Modified: Thu, 02 Apr 2026 01:00:00 GMT
Connection: keep-alive
ETag: “66026400-264”
Accept-Ranges: bytes

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.

For online documentation and support please refer to
nginx.org.
Commercial support is available at
nginx.com.

Thank you for using nginx.

Connection closed by foreign host.

# 3. 测试HTTPS端口(443)
# telnet 192.168.1.100 443
Trying 192.168.1.100…
Connected to 192.168.1.100.
Escape character is ‘^]’.
^]
telnet> quit
Connection closed.

# 4. 测试MySQL端口(3306)
# telnet 192.168.1.100 3306
Trying 192.168.1.100…
Connected to 192.168.1.100.
Escape character is ‘^]’.
J 5.7.40-log
^]
telnet> quit
Connection closed.

3.3.2 使用nc测试端口

# 1. 测试TCP端口
# nc -zv 192.168.1.100 22
Connection to 192.168.1.100 22 port [tcp/*] succeeded!

# 2. 测试UDP端口
# nc -zuv 192.168.1.100 53
Connection to 192.168.1.100 53 port [udp/*] succeeded!

# 3. 批量测试多个端口
# nc -zv 192.168.1.100 22 80 443 3306
Connection to 192.168.1.100 22 port [tcp/*] succeeded!
Connection to 192.168.1.100 80 port [tcp/*] succeeded!
Connection to 192.168.1.100 443 port [tcp/*] succeeded!
Connection to 192.168.1.100 3306 port [tcp/*] succeeded!

# 4. 指定超时时间
# nc -zv -w 3 192.168.1.100 22
Connection to 192.168.1.100 22 port [tcp/*] succeeded!

# 5. 扫描端口范围
# nc -zv 192.168.1.100 20-30
Connection to 192.168.1.100 22 port [tcp/*] succeeded!

风哥提示:网络连通性测试是网络故障排查的基础,建议按照分层排查的原则,从底层到高层逐层测试。学习交流加群风哥QQ113257174

Part04-生产案例与实战讲解

4.1 网络不可达故障排查

4.1.1 网络不可达故障排查步骤

# 问题现象:ping外网地址失败
# ping 8.8.8.8
connect: Network is unreachable

# 排查步骤1:检查网络接口状态
# ip addr show
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever

# 排查步骤2:检查路由表
# ip route show
default via 192.168.1.1 dev eth0 proto static metric 100
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.100 metric 100

# 排查步骤3:检查网关连通性
# ping -c 4 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.456 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.458 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.455 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.457 ms

— 192.168.1.1 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 0.455/0.456/0.458/0.001 ms

# 排查步骤4:检查DNS解析
# nslookup www.baidu.com
Server: 192.168.1.1
Address: 192.168.1.1#53

Non-authoritative answer:
Name: www.baidu.com
Address: 110.242.68.4
Name: www.baidu.com
Address: 110.242.68.3

# 排查步骤5:检查防火墙规则
# firewall-cmd –list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: ssh dhcpv6-client
ports:
protocols:
forward: yes
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:

# 排查步骤6:检查网络配置文件
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=12345678-1234-1234-1234-123456789012
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.1.100
PREFIX=24
GATEWAY=192.168.1.1
DNS1=192.168.1.1

# 解决方案:重启网络服务
# systemctl restart NetworkManager

# 验证:再次测试网络连通性
# ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=116 time=12.345 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=116 time=12.346 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=116 time=12.344 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=116 time=12.345 ms

— 8.8.8.8 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 12.344/12.345/12.346/0.000 ms

4.2 端口不可达故障排查

4.2.1 端口不可达故障排查步骤

# 问题现象:telnet端口连接失败
# telnet 192.168.1.100 80
Trying 192.168.1.100…
telnet: connect to address 192.168.1.100: Connection refused

# 排查步骤1:确认网络连通性
# ping -c 4 192.168.1.100
PING 192.168.1.100 (192.168.1.100) 56(84) bytes of data.
64 bytes from 192.168.1.100: icmp_seq=1 ttl=64 time=0.456 ms
64 bytes from 192.168.1.100: icmp_seq=2 ttl=64 time=0.458 ms
64 bytes from 192.168.1.100: icmp_seq=3 ttl=64 time=0.455 ms
64 bytes from 192.168.1.100: icmp_seq=4 ttl=64 time=0.457 ms

— 192.168.1.100 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 0.455/0.456/0.458/0.001 ms

# 排查步骤2:检查目标服务器端口监听状态
# ssh root@192.168.1.100 “ss -tlnp | grep :80”
LISTEN 0 128 *:80 *:* users:((“nginx”,pid=1234,fd=6))

# 排查步骤3:检查目标服务器防火墙规则
# ssh root@192.168.1.100 “firewall-cmd –list-all”
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: ssh dhcpv6-client
ports:
protocols:
forward: yes
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:

# 排查步骤4:检查本地防火墙规则
# firewall-cmd –list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: ssh dhcpv6-client
ports:
protocols:
forward: yes
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:

# 排查步骤5:使用nc测试端口
# nc -zv 192.168.1.100 80
nc: connect to 192.168.1.100 port 80 (tcp) failed: Connection refused

# 解决方案:在目标服务器开放HTTP端口
# ssh root@192.168.1.100 “firewall-cmd –permanent –add-service=http”
success
# ssh root@192.168.1.100 “firewall-cmd –reload”
success

# 验证:再次测试端口连通性
# telnet 192.168.1.100 80
Trying 192.168.1.100…
Connected to 192.168.1.100.
Escape character is ‘^]’.
^]
telnet> quit
Connection closed.

# 验证:使用nc测试端口
# nc -zv 192.168.1.100 80
Connection to 192.168.1.100 80 port [tcp/*] succeeded!

4.3 丢包问题排查

4.3.1 丢包问题排查步骤

# 问题现象:ping测试出现丢包
# ping -c 10 192.168.1.100
PING 192.168.1.100 (192.168.1.100) 56(84) bytes of data.
64 bytes from 192.168.1.100: icmp_seq=1 ttl=64 time=0.456 ms
64 bytes from 192.168.1.100: icmp_seq=2 ttl=64 time=0.458 ms
64 bytes from 192.168.1.100: icmp_seq=3 ttl=64 time=0.455 ms
64 bytes from 192.168.1.100: icmp_seq=4 ttl=64 time=0.457 ms
64 bytes from 192.168.1.100: icmp_seq=6 ttl=64 time=0.456 ms
64 bytes from 192.168.1.100: icmp_seq=7 ttl=64 time=0.458 ms
64 bytes from 192.168.1.100: icmp_seq=8 ttl=64 time=0.455 ms
64 bytes from 192.168.1.100: icmp_seq=10 ttl=64 time=0.457 ms

— 192.168.1.100 ping statistics —
10 packets transmitted, 8 received, 20% packet loss, time 9008ms
rtt min/avg/max/mdev = 0.455/0.456/0.458/0.001 ms

# 排查步骤1:检查网络接口统计信息
# ip -s link show eth0
2: eth0: mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
12345678 123456 0 10 0 0
TX: bytes packets errors dropped carrier collsns
23456789 234567 0 5 0 0

# 排查步骤2:检查网络接口错误
# ethtool -S eth0 | grep -i error
rx_errors: 0
tx_errors: 0
rx_crc_errors: 0
rx_frame_errors: 0
rx_fifo_errors: 0
rx_missed_errors: 0

# 排查步骤3:检查网络接口速率和双工模式
# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Link detected: yes

# 排查步骤4:检查网络负载
# sar -n DEV 1 5
Linux 5.14.0-284.el10.x86_64 (server1) 04/02/2026 _x86_64_ (4 CPU)

10:00:00 AM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
10:00:01 AM eth0 123.45 234.56 12.34 23.45 0.00 0.00 0.00 0.12
10:00:02 AM eth0 124.56 235.67 12.45 23.56 0.00 0.00 0.00 0.13
10:00:03 AM eth0 125.67 236.78 12.56 23.67 0.00 0.00 0.00 0.14
10:00:04 AM eth0 126.78 237.89 12.67 23.78 0.00 0.00 0.00 0.15
10:00:05 AM eth0 127.89 238.90 12.78 23.89 0.00 0.00 0.00 0.16
Average: eth0 125.67 236.76 12.56 23.67 0.00 0.00 0.00 0.14

# 排查步骤5:检查网络连接数
# ss -s
Total: 1234
TCP: 456 (estab 234, closed 222, orphaned 0, timewait 123)
Transport Total IP IPv6
* – – –
RAW 0 0 0
UDP 78 56 22
TCP 456 345 111
INET 534 401 133
FRAG 0 0 0

# 解决方案:优化网络参数
# sysctl -w net.core.rmem_max=16777216
# sysctl -w net.core.wmem_max=16777216
# sysctl -w net.ipv4.tcp_rmem=’4096 87380 16777216′
# sysctl -w net.ipv4.tcp_wmem=’4096 65536 16777216′

# 验证:再次测试网络连通性
# ping -c 10 192.168.1.100
PING 192.168.1.100 (192.168.1.100) 56(84) bytes of data.
64 bytes from 192.168.1.100: icmp_seq=1 ttl=64 time=0.456 ms
64 bytes from 192.168.1.100: icmp_seq=2 ttl=64 time=0.458 ms
64 bytes from 192.168.1.100: icmp_seq=3 ttl=64 time=0.455 ms
64 bytes from 192.168.1.100: icmp_seq=4 ttl=64 time=0.457 ms
64 bytes from 192.168.1.100: icmp_seq=5 ttl=64 time=0.456 ms
64 bytes from 192.168.1.100: icmp_seq=6 ttl=64 time=0.458 ms
64 bytes from 192.168.1.100: icmp_seq=7 ttl=64 time=0.455 ms
64 bytes from 192.168.1.100: icmp_seq=8 ttl=64 time=0.457 ms
64 bytes from 192.168.1.100: icmp_seq=9 ttl=64 time=0.456 ms
64 bytes from 192.168.1.100: icmp_seq=10 ttl=64 time=0.458 ms

— 192.168.1.100 ping statistics —
10 packets transmitted, 10 received, 0% packet loss, time 9010ms
rtt min/avg/max/mdev = 0.455/0.456/0.458/0.001 ms

生产环境建议:建议使用专业的网络监控系统(如Zabbix、Prometheus)进行网络监控,配置合理的告警机制,及时发现网络问题。更多视频教程www.fgedu.net.cn

Part05-风哥经验总结与分享

5.1 网络排查最佳实践

网络故障排查最佳实践:

  • 分层排查:从物理层到应用层逐层排查
  • 分段排查:从本地到远程分段测试
  • 工具组合:使用多种工具进行综合诊断
  • 日志分析:分析系统日志和网络日志
  • 文档记录:记录排查过程和解决方案
  • 预防措施:建立网络监控和告警机制
  • 定期巡检:定期检查网络设备和配置

5.2 性能优化建议

网络性能优化建议:

# 网络性能优化
# 1. 优化网络缓冲区
# cat >> /etc/sysctl.conf << 'EOF' # 网络缓冲区优化 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.ipv4.tcp_rmem = 4096 87380 16777216 net.ipv4.tcp_wmem = 4096 65536 16777216 # TCP连接优化 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.tcp_max_syn_backlog = 8192 net.ipv4.tcp_tw_reuse = 1 # 网络队列优化 net.core.netdev_max_backlog = 5000 net.core.somaxconn = 1024 EOF # 2. 应用网络参数 # sysctl -p # 3. 验证网络参数 # sysctl -a | grep -E "rmem|wmem|tcp" net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.ipv4.tcp_rmem = 4096 87380 16777216 net.ipv4.tcp_wmem = 4096 65536 16777216 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.tcp_max_syn_backlog = 8192 net.ipv4.tcp_tw_reuse = 1 net.core.netdev_max_backlog = 5000 net.core.somaxconn = 1024

5.3 工具推荐

推荐的网络测试工具:

  • ping:ICMP连通性测试工具
  • traceroute:路由路径追踪工具
  • mtr:结合ping和traceroute的网络诊断工具
  • telnet:TCP端口测试工具
  • nc:多功能网络工具
  • nmap:端口扫描工具
  • iftop:实时网络流量监控工具
  • nload:网络负载监控工具
风哥提示:网络故障排查需要系统性的方法,建议按照分层排查的原则,从底层到高层逐层测试。对于复杂的网络问题,建议使用专业的网络诊断工具(如Wireshark)进行深入分析。学习交流加群风哥微信: itpux-com

本文档介绍了基础网络连通性测试与故障排查,包括网络连通性测试的概念、常用网络测试工具、故障排查方法、常见问题处理等内容。通过合理的网络测试和排查,可以快速定位和解决网络问题,保障系统稳定运行。更多学习教程公众号风哥教程itpux_com

本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html

联系我们

在线咨询:点击这里给我发消息

微信号:itpux-com

工作日:9:30-18:30,节假日休息