ubuntu 旧版本
修改interfaces
sudo vi /etc/network/interfaces
auto enp1s0 # 网卡名称
iface enp1s0 inet static #设置为静态IP
address 192.168.1.100 # 本机IP
netmask 255.255.255.0 # 子网掩码
gateway 192.168.0.1 # 网关
增加DNS
sudo vi /etc/resolv.conf
nameserver 223.5.5.5
nameserver 8.8.8.8
重启
reboot
ubuntu 新版本
sudo vi /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
# 网卡名称
eno1:
# 禁用DHCP
dhcp4: false
# 本机IP/子网掩码
addresses: [192.168.0.20/24]
# 网关
routes:
- to: default
via: 192.168.0.1
nameservers:
addresses: [223.5.5.5, 114.114.114.114]
version: 2
netnetplan applyplan apply
netplan apply
评论区