在 Debian 中,ifconfig 用来查看和配置网络接口。需要注意的是:
ifconfig,因为它属于 已废弃的 net-tools 包ip 命令(iproute2)下面分情况说明。
sudo apt update
sudo apt install net-tools
安装完成后即可使用:
ifconfig
ifconfig -a
ifconfig eth0
ifconfig
输出中:
inet → IPv4 地址inet6 → IPv6 地址示例:
inet 192.168.1.100 netmask 255.255.255.0
查看所有网卡和 IP:
ip addr
# 或
ip a
查看某个网卡:
ip addr show eth0
| 功能 | ifconfig | ip 命令 |
|---|---|---|
| 查看 IP | ifconfig | ip addr |
| 启用网卡 | ifconfig eth0 up | ip link set eth0 up |
| 禁用网卡 | ifconfig eth0 down | ip link set eth0 down |
| 查看路由 | route -n | ip route |
bash: ifconfig: command not found
✅ 解决:
sudo apt install net-tools
如果你愿意,可以告诉我:
我可以给你更精确的命令 ✅