在 Debian 里,ifconfig 属于比较老的网络工具,现在已经默认不再安装。下面分情况说明怎么用。
ifconfig 来自 net-tools 软件包ip 命令)bash: ifconfig: command not found
如果你确实想用 ifconfig,可以手动安装:
sudo apt update
sudo apt install net-tools
安装完成后即可使用:
ifconfig
ifconfig
或(包括未启用的网卡):
ifconfig -a
ifconfig eth0
sudo ifconfig eth0 up
sudo ifconfig eth0 down
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
sudo route add default gw 192.168.1.1
Debian 官方更推荐 ip 命令:
ip addr
sudo ip link set eth0 up
sudo ip link set eth0 down
sudo ip addr add 192.168.1.100/24 dev eth0
sudo ip route add default via 192.168.1.1
ifconfig / ip/etc/network/interfaces例如 /etc/network/interfaces:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
✅ 想用 ifconfig → 装 net-tools
✅ 新系统 → 推荐用 ip
✅ 临时配置 → ip / ifconfig
✅ 永久配置 → /etc/network/interfaces 或 NetworkManager
如果你愿意,可以告诉我:
我可以给你更精确的配置示例。