在 Debian 系统中,ifconfig 命令来自 net-tools 软件包。现代 Debian(如 Debian 10/11/12)默认不再安装 net-tools,所以你可能遇到 ifconfig: command not found。
sudo apt update
sudo apt install net-tools
安装完成后即可使用:
ifconfig
假设网卡名为 eth0:
sudo ifconfig eth0 up
配置 IP(示例):
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
开启网卡并启用 DHCP(需配合 dhclient):
sudo ifconfig eth0 up
sudo dhclient eth0
ifconfig -a
如果网卡状态是 DOWN,说明未启用。
Debian 更推荐使用 ip 命令:
ip link set eth0 up
ip addr show
以及 NetworkManager / systemd-networkd 进行长期配置。
编辑:
sudo nano /etc/network/interfaces
示例:
auto eth0
iface eth0 inet dhcp
或静态 IP:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
重启网络:
sudo systemctl restart networking
如果你愿意,可以告诉我:
ip a 输出)我可以给你更精确的配置方案。