vi /etc/netplan/01-network-manager-all.yaml
version: 2
renderer: networkd
ethernets:
ens33:
addresses: [192.168.0.55/24]
gateway4: 192.168.0.1
nameservers:
addresses: [223.5.5.5, 223.6.6.6]
sudo netplan apply
version: 2
renderer: networkd #NetworkManager 桌面版 networkd:服务器和无头
ethernets:
ens33: #更改为ip a里的名称
dhcp4: false
addresses: [192.168.0.55/24]
optional: true
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [223.5.5.5, 223.6.6.6]
vi /etc/netplan/01-installer-config.yaml #文件名可以定义
# This is the network config written by 'subiquity'
network:
version: 2
ethernets:
ens3:
dhcp4: no
dhcp6: no
addresses:
- 202.119.197.216/24
- 2001:DA8:100D:AD::942:216/116
routes:
- to: default
via: 202.119.197.1
- to: default
via: "2001:DA8:100D:AD::942:1"
nameservers:
addresses:
- 114.114.114.114
- 2400:3200::1
#或者
addresses: [114.114.114.114,8.8.4.4]
network:
version: 2
ethernets:
eth0:
dhcp4: true
match:
macaddress: 52:54:00:45:b4:e8
set-name: eth0
routes: # 从这里开始是新加的
- to: default
via: "2402:4e00:1409:4a02::1"