在 Debian(以及大多数现代 Linux 发行版)中,ifconfig 已被 iproute2 套件取代,推荐使用 ip 命令。下面给你一个对照速查表,方便从 ifconfig 平滑迁移。
ifconfig 属于 net-tools,已多年不维护ip 命令功能更强、更统一net-toolsifconfig
ifconfig
ip(推荐)
ip addr
# 或简写
ip a
只查看某个接口:
ip addr show eth0
ifconfig
ifconfig eth0 up
ifconfig eth0 down
ip
ip link set eth0 up
ip link set eth0 down
ifconfig
ifconfig eth0 192.168.1.100 netmask 255.255.255.0
ip
ip addr add 192.168.1.100/24 dev eth0
删除 IP:
ip addr del 192.168.1.100/24 dev eth0
ifconfig / route
route -n
ip
ip route
添加默认网关:
ip route add default via 192.168.1.1
删除默认网关:
ip route del default
ifconfig
ifconfig | grep ether
ip
ip link show
ifconfig/arp
arp -n
ip
ip neigh
⚠️ 注意:
ip 命令修改的是 运行时配置编辑:
sudo nano /etc/network/interfaces
示例:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
重启网络:
sudo systemctl restart networking
使用 NetworkManager 或 systemd-networkd
nmcli device status
nmcli con show
安装旧工具:
sudo apt update
sudo apt install net-tools
⚠️ 不推荐长期使用
Debian 中,用
ip替代ifconfig,用nmcli或/etc/network/interfaces做永久配置。
如果你愿意,我可以: