在 Debian(以及大多数现代 Linux 发行版)中,ifconfig 和 ip 都用于查看和配置网络接口,但它们有本质区别,简单说:
ifconfig是旧工具,已逐步淘汰;ip是新标准,功能更强。
ifconfigip| 功能 | ifconfig | ip |
|---|---|---|
| 查看 IP 地址 | ✅ | ✅ |
| 启用/禁用网卡 | ✅ | ✅ |
| 配置 IP | ✅(有限) | ✅(完整) |
| 路由表管理 | ❌(需用 route) | ✅ |
| VLAN / 隧道 | ❌ | ✅ |
| 策略路由 | ❌ | ✅ |
| 命名空间 | ❌ | ✅ |
| 与内核一致性 | 弱 | 强 |
ifconfig
ip addr show
# 或简写
ip a
ifconfig eth0 up
ifconfig eth0 down
ip link set eth0 up
ip link set eth0 down
ifconfig eth0 192.168.1.10 netmask 255.255.255.0
ip addr add 192.168.1.10/24 dev eth0
route -n
ip route show
ifconfig 不够用?ifconfigroutearpnetstat而 ip 一个工具几乎全覆盖。
ipifconfigifconfig 可自行替换为 ip如需安装旧工具(不推荐):
sudo apt install net-tools
ifconfig是过去,ip是现在和未来。
如果你愿意,我也可以帮你把常用 ifconfig 命令逐一改写成 ip 写法。