ifconfig 和 ip 命令在 Linux 系統中都用于配置和顯示網絡接口信息,但它們之間存在一些關鍵區別:
ifconfig:
ip:
iproute2 包的一部分。ifconfig 的替代品,并且在大多數現代 Linux 發行版中默認安裝。ifconfig:
ip:
ifconfig:
ifconfig eth0 up 或 ifconfig eth0 192.168.1.100 netmask 255.255.255.0ip:
ip addr add 192.168.1.100/24 dev eth0 或 ip link set eth0 upifconfig:
ip:
ip 命令。設置 IP 地址:
ifconfig eth0 192.168.1.100ip addr add 192.168.1.100/24 dev eth0啟用接口:
ifconfig eth0 upip link set eth0 up查看路由表:
route -n(舊方法)ip route show雖然 ifconfig 在某些情況下仍然有用,但鑒于其過時的狀態和 ip 命令的強大功能,建議優先使用 ip 命令來進行網絡配置和管理。這不僅有助于保持系統的現代化,還能提供更好的性能和靈活性。