在 Debian(以及大多数现代 Linux 发行版)中,ifconfig 和 ip 都是用于查看和配置网络接口的工具,但它们来自不同的工具集,功能和定位有明显区别。
ifconfigip| 功能 | ifconfig | ip |
|---|---|---|
| 查看网卡信息 | ✅ | ✅ |
| 配置 IP 地址 | ✅(有限) | ✅(更强) |
| 路由管理 | ❌(需 route) | ✅ |
| VLAN / 隧道 / 策略路由 | ❌ | ✅ |
| 网络命名空间 | ❌ | ✅ |
| 输出信息详细程度 | 较简单 | 更详细 |
| 是否维护 | ❌ 停止维护 | ✅ 活跃维护 |
ifconfig
ip addr show
# 或简写
ip a
✅ ip 显示更完整(如 scope、state)
route -n
ip route
✅ ip route 是标准方式
ifconfig eth0 192.168.1.10 netmask 255.255.255.0
ip addr add 192.168.1.10/24 dev eth0
⚠️ ifconfig 修改是临时的,且不支持 CIDR 直观写法
ifconfig eth0 up
ifconfig eth0 down
ip link set eth0 up
ip link set eth0 down
ifconfig eth0
ip link show eth0
ipifconfig 对某些新特性不支持ip 可统一管理:
ifconfigwhich ifconfig
若没有:
sudo apt install net-tools
✅ 但不建议长期使用
ifconfig是“老工具”,能用但不推荐;ip是“现代标准”,功能更强、官方推荐。
如果你愿意,我也可以: