一、修改配置/etc/netplan
``
root@y36-server-ubuntucom:~# cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
enp7s0:
dhcp4: true
dhcp6: false
version: 2
bridges:
bri0:
interfaces: [enp7s0]
addresses: [192.168.107.67/24]
gateway4: 192.168.107.254
routes:
- to: default
via: 192.168.99.1
nameservers:
addresses:
- 114.114.114.114
- 8.8.8.8
- 8.8.4.4
parameters:
stp: true
forward-delay: 4
dhcp4: no
切记:注意缩进
二、测试文件配置文件是否有误
root@y36-server-ubuntucom:~# sudo netplan try
三、应用配置文件
root@y36-server-ubuntucom:~# sudo netplan apply
评论 (0)