在现代的 Linux 发行版中,ifconfig 并不是“不存在”,而是默认不再安装 / 不推荐使用了。原因主要有以下几点:
ifconfig 属于已废弃的工具集(net-tools)ifconfig 来自 net-tools 软件包,这个包:
很多发行版(如 Ubuntu 18.04+、Debian 10+、CentOS 8+)默认不再安装 net-tools。
ip 命令取代(iproute2)Linux 网络管理的“正统”工具现在是:
ip
例如:
ip addr # 替代 ifconfig
ip link # 查看/管理网卡
ip route # 替代 route
ip neigh # 替代 arp
ip 命令:
通常是因为:
command not found: ifconfig
这是因为 net-tools 没装。
你可以手动安装(不推荐长期使用):
# Debian / Ubuntu
sudo apt install net-tools
# CentOS / RHEL
sudo yum install net-tools
| ifconfig | ip 命令 |
|---|---|
| ifconfig | ip addr |
| ifconfig eth0 up | ip link set eth0 up |
| ifconfig eth0 192.168.1.10 | ip addr add 192.168.1.10/24 dev eth0 |
| route | ip route |
Linux 不是没有 ifconfig,而是“不再默认提供,也不建议再用”。
如果你愿意,我可以:
ifconfig 命令翻译成 ip 命令ip