操作目的如题:
修改网络配置文件:
sudo vim /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.
# 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
nameservers:
addresses:
- 202.118.66.6
search: []
optional: true
enp8s0:
addresses:
- 192.168.11.66/24
gateway4: 192.168.11.254
nameservers:
addresses:
- 202.118.66.6
search: []
optional: true
version: 2
编辑完后,执行命令:
sudo netplan apply
其中, 网卡 enp7s0 设置为动态获取ip, 网卡 enp8s0 设置为静态ip 。
==================================================================
常用的相关命令:
查看网络设备配置:
ip a
查看网络硬件:
lspci |grep Eth