# 語法
ip link set dev <介面> mtu <值>
ifconfig <介面> mtu <值> up
# 範例:啟用 Jumbo Frame
ip link set dev eth0 mtu 9000
# 驗證
ip link show eth0 | grep mtu
# NetworkManager (推薦)
nmcli con mod "System eth0" 802-3-ethernet.mtu 9000
nmcli con up "System eth0"
# 傳統 network-scripts
vi /etc/sysconfig/network-scripts/ifcfg-eth0
MTU=9000
# IPv6 另加
IPV6_MTU=1280
systemctl restart network
# /etc/network/interfaces (傳統)
auto eth0
iface eth0 inet static
address 192.168.1.10/24
gateway 192.168.1.1
mtu 9000
# Netplan (Ubuntu 18.04+)
# /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
eth0:
mtu: 9000
addresses: [192.168.1.10/24]
gateway4: 192.168.1.1
# 套用
netplan apply
# systemd-networkd
# /etc/systemd/network/10-eth0.network
[Link]
MTUBytes=9000
systemctl restart systemd-networkd
system mtu 9000 (全域) 或 interface gi1/0/1; mtu 9000。jumboframe enable / mtu 9000。注意:僅修改主機 MTU 而交換機未啟用,會導致大封包被丟棄、連線不穩。
# ping 測試 (Linux/macOS)
ping -M do -s 1472 192.168.1.1 # 1472 + 28 (IP+ICMP頭) = 1500
# 逐步增加 -s 數值直到出現 "local error: Message too long"
# 最大成功值 + 28 = 實際可用 MTU
# Windows
ping -f -l 1472 192.168.1.1
# 自動化腳本探測
for mtu in {1500..9000..100}; do
if ping -c 1 -M do -s $((mtu-28)) 192.168.1.1 >/dev/null 2>&1; then
echo "MTU $mtu OK"
else
echo "MTU $mtu FAIL"; break
fi
done
# iptables 調整 MSS (通常 = MTU - 40)
iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1460
# nftables
nft add rule ip filter forward tcp flags syn tcp option maxseg size set 1460