在 Debian 里,ifconfig 属于 net-tools 工具包,而较新版本(Debian 9 及以后)默认没有安装这个包,所以直接运行会提示命令找不到。
which ifconfig
或
ifconfig
如果提示:
bash: ifconfig: command not found
说明没装。
sudo apt update
sudo apt install net-tools
安装完成后即可使用:
ifconfig
ifconfig # 查看所有网卡
ifconfig eth0 # 查看指定网卡
ifconfig eth0 up # 启用网卡
ifconfig eth0 down # 禁用网卡
ifconfig eth0 192.168.1.100 netmask 255.255.255.0 # 临时配置 IP
⚠️ 这些配置重启后失效
Debian 官方更推荐使用 ip 命令:
ip addr # 相当于 ifconfig
ip link # 查看网卡状态
ip link set eth0 up
apt install net-tools 安装ip 命令如果你是 服务器 / 桌面版 / 容器环境,可以告诉我,我可以给你更具体的命令。