在 Debian 中,ifconfig 通常用于查看或临时配置网络接口,但它不会持久化(重启后失效)。下面分情况说明。
新版本 Debian 默认可能没有 ifconfig:
sudo apt update
sudo apt install net-tools
ifconfig
或
ifconfig -a
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0 up
eth0:网卡名(可能是 ens33、enp0s3 等)up:启用接口sudo route add default gw 192.168.1.1
或
sudo ip route add default via 192.168.1.1
编辑(或创建):
sudo nano /etc/resolv.conf
写入:
nameserver 8.8.8.8
nameserver 114.114.114.114
⚠️ 若系统使用 systemd-resolved,重启可能被覆盖。
sudo ifconfig eth0 down
sudo ifconfig eth0 up
/etc/network/interfacessudo nano /etc/network/interfaces
示例(静态 IP):
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 114.114.114.114
应用配置:
sudo systemctl restart networking
nmtui
或
nmcli
如果你告诉我:
ip a 输出)我可以给你精确命令。