Ubuntu18
1. 修改IP、网关、子网掩码
sudo vim /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.3.177
gateway 192.168.1.1 # 在本地确认
netmask 255.255.255.0 # 在本地确认
network 192.168.0.0
broadcast 192.168.0.255
2. 修改DNS
sudo vim /etc/resolv.conf
nameserver 114.114.114.114
3. 重启网卡
sudo /etc/init.d/network restart
Centos7
1. 修改IP、网关、子网掩码、DNS
vim /etc/sysconfig/network-scripts/ifcfg-eno1 # 需确定具体网卡
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
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=eno1
UUID=400d083d-0f87-4488-b592-60550e280caf
DEVICE=eno1
ZONE=public
BOOTPROTO=static # 静态ip
IPADDR=192.168.2.90
NETMASK=255.255.240.0
GATEWAY=192.168.1.1
DNS1=114.114.114.114
ONBOOT=yes # 开机生效
2. 重启服务
service network restart