1 ubuntu
vim /etc/netplan/00-network-manager-all.yaml
network:
ethernets:
ens160:
dhcp4: false
dhcp6: false
addresses: [10.10.10.222/24]
routes:
- to: default
via: 10.10.10.1
nameservers:
addresses: [8.8.8.8,114.114.114.114]
version: 2
netplan apply
最后重启系统
2 linux
# 此处的ens192需要看自己服务器的具体是多少
vi /etc/sysconfig/network-scripts/ifcfg-ens192
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens192
UUID=e9d1c567-fb18-4104-986d-8eeada0d77dd
DEVICE=ens192
ONBOOT=yes
IPADDR=10.10.10.221
PREFIX=24
GATEWAY=10.10.10.1
NETMASK=255.255.255.0
DNS1=8.8.8.8
IPV6_PRIVACY=no
ZONE=public
service network restart
最后重启服务器就可以了