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 eth0
sudo ip route add default via 192.168.1.1
/etc/resolv.conf
添加 nameserver 8.8.8.8
。ip addr show eth0
ping 8.8.8.8
。注意:根據實際網絡接口名稱(如 enp0s3
等)調整配置中的 eth0
,確保配置文件語法正確。