Linux 网络协议栈是一个分层的体系结构,遵循 OSI 模型和 TCP/IP 模型。以下是最常见的网络协议及其功能详解,按分层结构组织:
igb
、e1000e
)和内核的 net/core/ethernet.c
。bash
arp -a # 查看ARP缓存
ip neigh # 现代替代命令
pppd
、rp-pppoe
。bash
ip addr show # 查看IP地址
sysctl net.ipv4.* # 调整IPv4参数
ping
、traceroute
)。bash
ping -c 4 example.com
traceroute -I example.com
ip route add
)。Quagga
/FRRouting
)、BGP(Bird
)。bash
ss -tulnp # 查看TCP/UDP连接
tcpdump -i eth0 'tcp port 80'
bash
nc -u <host> <port> # UDP测试
sctp
内核模块。curl
、wget
、nginx/apache
。bash
dig example.com
systemd-resolve --status
isc-dhcp-server
;客户端:dhclient
。vsftpd
)。OpenSSH
)。net-snmp
)。bash
ip link add link eth0 name eth0.100 type vlan id 100
OpenVPN
、StrongSwan
)。bash
ip xfrm state # 查看IPSec状态
libp2p
实现)。ethtool
:调整网卡参数(如 offload)。
bash
ethtool -k eth0 | grep tx-checksumming
sysctl
:内核参数优化(如 TCP 窗口大小)。
bash
sysctl -w net.ipv4.tcp_window_scaling=1
bpfilter
:高性能包过滤(替代 iptables
)。ss
/netstat
检查端口状态。ethtool -S eth0
查看统计。tcpping
测量 TCP 延迟。ping -s 1472 -M do example.com
测试。通过理解这些协议的分层协作,可以高效诊断网络问题(如 MTU 不匹配、ARP 欺骗)或优化性能(如调整 TCP 缓冲区)。