温馨提示×

debian ifconfig命令不存在

小樊
45
2026-09-12 11:11:33
栏目: 智能运维

在较新版本的 Debian(如 Debian 9 及以后)中,ifconfig 命令默认不再安装,因为它属于 net-tools 工具包,而 Debian 推荐使用 iproute2 工具包中的 ip 命令来替代。

解决方法一:安装 net-tools(恢复 ifconfig)

如果你确实需要使用 ifconfig,可以安装 net-tools:

sudo apt update
sudo apt install net-tools

安装完成后即可使用:

ifconfig

解决方法二:使用推荐的 ip 命令(无需安装)

现代 Debian 推荐使用 ip 命令,功能更强大:

  • 查看网络接口信息:

    ip addr
    

    或简写:

    ip a
    
  • 查看路由:

    ip route
    
  • 启用 / 禁用网卡:

    sudo ip link set eth0 up
    sudo ip link set eth0 down
    
  • 配置 IP 地址:

    sudo ip addr add 192.168.1.100/24 dev eth0
    

总结

  • ifconfig 不存在是正常现象
  • 临时用:安装 net-tools
  • 长期用:学习并使用 ip 命令(官方推荐)

如果你是在脚本或老教程中遇到这个问题,也可以告诉我具体用途,我可以帮你改写成 ip 命令版本。

0 踩