打开配置文件
[root@docker ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
配置文件内容如下 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=ens33 UUID=1797bb2f-b22a-43e2-9ab6-be68d3a1944a DEVICE=ens33 BOOTPROTO=static ONBOOT=yes NETMASK=255.255.255.0 DNS1=8.8.8.8 DNS2=114.114.114.114 IPADDR=172.20.10.10 GETEWAY=172.20.10.1
[root@docker ~]# vi /etc/sysconfig/network NETWORKING=yes # 网络是否工作,此处一定不能为no NETWORKING_IPV6=no HOSTNAME=docker GATEWAY=172.20.10.1
[root@docker ~]# vi /etc/resolv.conf search localdomain nameserver 8.8.8.8 nameserver 114.114.114.114
关闭防火墙 systemctl stop firewalld # 临时关闭防火墙 systemctl disable firewalld # 禁止开机启动
重启网卡 service network restart