系统
使用的系统Ubuntu22.04
配置网卡
网卡配置文件方法一
修改/etc/netplan里面的配置文件,如果没有文件的话使用方法二修改网卡配置文件
vim /etc/netplan/50-cloud-init.yaml
内容如下
network:
version: 2
ethernets:
eth0:
dhcp4: true
addresses: [110.110.110.110/32] # 此处为公网ip
match:
macaddress: 52:54:00:a4:51:df
set-name: eth0
重启网卡
netplan apply
网卡配置文件方法二
如果/etc/netplan下面没有网卡配置文件的话,编辑网卡配置文件/etc/network/interfaces.d/50-cloud-init.cfg
vim /etc/network/interfaces.d/50-cloud-init.cfg
内容如下
allow-hotplug eth0
auto eth0
iface eth0 inet dhcp
auto eth0:1
iface eth0:1 inet static
address 此处为公网ip
netmask 255.255.255.255
重启网卡
/etc/init.d/networking restart