在Debian系统中配置网络通常涉及修改网络配置文件或使用网络管理工具。以下是一些常见的方法:
sudo apt update
sudo apt install netplan
/etc/netplan/
目录下,文件名可能是01-netcfg.yaml
或类似名称。使用文本编辑器打开文件,例如:sudo nano /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 ifconfig eth0 192.168.1.100 netmask 255.255.255.0
sudo route add default gw 192.168.1.1
/etc/resolv.conf
文件,添加DNS服务器地址:echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolv.conf
echo "nameserver 8.8.4.4" | sudo tee -a /etc/resolv.conf
sudo apt update
sudo apt install network-manager
sudo systemctl enable NetworkManager
sudo systemctl start NetworkManager
nmcli
命令行工具来管理网络连接。例如,使用nmcli
命令添加一个新的有线连接:sudo nmcli connection add type ethernet con-name "Wired Connection" ifname eth0 ssid "YourNetworkSSID" --hidden yes
sudo nmcli connection modify "Wired Connection" ipv4.addresses "192.168.1.100/24" ipv4.gateway "192.168.1.1" ipv4.method "manual"
sudo nmcli connection up "Wired Connection"
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:Debian Java网络配置是什么