温馨提示×

为什么linux没有ifconfig

小樊
38
2026-09-05 02:55:50
栏目: 智能运维

现代的 Linux 发行版中ifconfig 并不是“不存在”,而是默认不再安装 / 不推荐使用了。原因主要有以下几点:


1. ifconfig 属于已废弃的工具集(net-tools)

ifconfig 来自 net-tools 软件包,这个包:

  • 开发停滞多年
  • 不支持很多现代网络特性(如 IPv6 完整支持、命名空间、策略路由等)
  • 被官方认为 legacy(过时)

很多发行版(如 Ubuntu 18.04+、Debian 10+、CentOS 8+)默认不再安装 net-tools


2. 被 ip 命令取代(iproute2)

Linux 网络管理的“正统”工具现在是:

ip

例如:

ip addr        # 替代 ifconfig
ip link        # 查看/管理网卡
ip route       # 替代 route
ip neigh       # 替代 arp

ip 命令:

  • 功能更强
  • 性能更好
  • 支持现代内核特性

3. 为什么你“找不到 ifconfig”

通常是因为:

command not found: ifconfig

这是因为 net-tools 没装

你可以手动安装(不推荐长期使用):

# Debian / Ubuntu
sudo apt install net-tools

# CentOS / RHEL
sudo yum install net-tools

4. 常见替代对照表

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

5. 总结一句话

Linux 不是没有 ifconfig,而是“不再默认提供,也不建议再用”。

如果你愿意,我可以:

  • 帮你把常用 ifconfig 命令翻译成 ip 命令
  • 或解释为什么服务器上更推荐 ip

0