Debian Minimal网络设置常用方法如下:
编辑 /etc/network/interfaces 文件:
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 8.8.4.4
auto eth0
iface eth0 inet dhcp
保存后重启网络:sudo systemctl restart networking。
安装netplan:sudo apt install netplan.io
编辑配置文件(如 /etc/netplan/01-netcfg.yaml):
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
addresses: [192.168.1.100/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
应用配置:sudo netplan apply。
安装:sudo apt install network-manager
nmcli con mod 'Wired connection 1' ipv4.addresses 192.168.1.100/24
nmcli con mod 'Wired connection 1' ipv4.gateway 192.168.1.1
nmcli con mod 'Wired connection 1' ipv4.dns "8.8.8.8"
nmcli con up 'Wired connection 1'
nm-connection-editor 工具编辑。sudo ip addr add 192.168.1.100/24 dev eth0sudo ip route add default via 192.168.1.1/etc/resolv.conf 添加 nameserver 8.8.8.8。ip addr show eth0ping 8.8.8.8。注意:根据实际网络接口名称(如 enp0s3 等)调整配置中的 eth0,确保配置文件语法正确。