ifconfig
是一個用于配置和顯示網絡接口參數的命令行工具。要使用 ifconfig
設置 MTU(最大傳輸單元)值,請按照以下步驟操作:
打開終端(在 Linux 和 macOS 上)或命令提示符/PowerShell(在 Windows 上)。
首先,找到要更改 MTU 值的網絡接口。運行以下命令:
對于 Linux 和 macOS:
ifconfig -a
對于 Windows:
ipconfig /all
在輸出中找到要更改 MTU 值的網絡接口,例如 eth0
(Linux/macOS)或 Ethernet adapter Ethernet
(Windows)。
使用 ifconfig
命令更改 MTU 值。將 <interface>
替換為網絡接口名稱,將 <mtu_value>
替換為您要設置的 MTU 值。以下是在不同操作系統上執行此操作的命令:
對于 Linux 和 macOS:
sudo ifconfig <interface> mtu <mtu_value>
例如,要將 MTU 值設置為 1400,您可以運行:
sudo ifconfig eth0 mtu 1400
對于 Windows:
netsh interface ipv4 set subinterface "<interface>" mtu=<mtu_value> store=persistent
例如,要將 MTU 值設置為 1400,您可以運行:
netsh interface ipv4 set subinterface "Ethernet adapter Ethernet" mtu=1400 store=persistent
關閉并重新打開網絡接口以使更改生效。這將取決于您的操作系統:
對于 Linux:
sudo ifconfig <interface> down
sudo ifconfig <interface> up
對于 macOS:
sudo ifconfig <interface> down
sudo ifconfig <interface> up
對于 Windows,您需要重啟計算機以使更改生效。
驗證 MTU 值已更改。再次運行 ifconfig
(Linux/macOS)或 ipconfig /all
(Windows)命令,檢查網絡接口的 MTU 值是否已更新為您設置的值。