ifconfig 是一個用于配置和顯示 Linux 內核中網絡接口的命令行實用程序。盡管現在許多系統已經轉向使用 ip 命令,但 ifconfig 仍然在許多系統中廣泛使用。以下是一些關于 ifconfig 命令的常見問題及其解答:
ifconfig -a
這個命令會顯示系統中所有網絡接口的詳細信息,包括未啟動的接口。
ifconfig eth0
將 eth0 替換為你想要查看的網絡接口名稱。
sudo ifconfig eth0 up
這個命令會啟動名為 eth0 的網絡接口。
sudo ifconfig eth0 down
這個命令會關閉名為 eth0 的網絡接口。
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
這個命令會為 eth0 接口分配 IP 地址 192.168.1.100 和子網掩碼 255.255.255.0。
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0 del
這個命令會刪除 eth0 接口上的 IP 地址 192.168.1.100。
ifconfig eth0 | grep hw
或者更簡潔地:
ethtool eth0 | grep link
這個命令會顯示 eth0 接口的 MAC 地址。
ifconfig eth0 | grep broadcast
這個命令會顯示 eth0 接口的廣播地址。
ethtool eth0 | grep MTU
這個命令會顯示 eth0 接口的 MTU 值。
sudo ifconfig eth0 mtu 1500
這個命令會將 eth0 接口的 MTU 設置為 1500 字節。
ifconfig 可能已經被 ip 命令取代。你可以使用 ip addr 和 ip link 來替代 ifconfig 的功能。希望這些常見問題及其解答能幫助你更好地理解和使用 ifconfig 命令。