1、 Ubuntu
Static IP: zhang@Ubuntu:~$ sudo vim /etc/netplan/50-cloud-init.yaml
network:
ethernets:
ens33:
addresses:[192.168.18.129/24]
dhcp4:false
gateway4:192.168.18.2
nameservers:
addresses:[8.8.8.8,114.114.114.114]
version:2
Restart the network service: sudo netplan apply
2、 Centos
Static IP: [root@Centos ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.18.128
GATEWAY=192.168.18.2
NETMASK=255.255.255.0
Configure DNS: [root@Centos ~]# vi /etc/resolv.conf
nameserver 114.114.114.114
nameserver 192.168.0.1
Restart network service: systemctl restart network.service
Recommended Posts