在较新的 Debian 版本中,ifconfig 已经被逐步淘汰,官方推荐使用 ip 命令来替代它,但 ifconfig 本身仍可使用,只是默认可能不再安装。
下面详细说一下:
从 Debian 9(Stretch)开始:
ifconfig 不再默认安装net-tools 软件包安装方式:
sudo apt update
sudo apt install net-tools
安装后就可以继续使用:
ifconfig
ip 来自 iproute2 包,默认已安装,功能更强。
| 功能 | ifconfig | ip 命令 |
|---|---|---|
| 查看网卡 | ifconfig |
ip addr 或 ip a |
| 启用网卡 | ifconfig eth0 up |
ip link set eth0 up |
| 禁用网卡 | ifconfig eth0 down |
ip link set eth0 down |
| 配置 IP | ifconfig eth0 192.168.1.10 |
ip addr add 192.168.1.10/24 dev eth0 |
| 查看路由 | route |
ip route |
| 查看 ARP | arp |
ip neigh |
ip原因:
ifconfig 已停止维护ip 支持更多网络特性(VLAN、VXLAN、策略路由等)ip 为主ifconfignet-tools 没问题ipnet-tools如果你愿意,我可以:
你想看哪个?