说明:本次说明是基于NAT的网络配置
1.系统安装好了以后ping了一下宿主机,通的,但就是无法连接外网,ip addr之后发现 ens33这块网卡没有ip地址
2.下面开始配置静态IP地址
cd /etc/sysconfig/network-scripts
vi ifcfg-ens33
------------------------------------------------------------------------------------------
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=ens33
UUID=09db5df2-31e3-4f18-84d9-5703aad1c6ee
DEVICE=ens33
ONBOOT=yes
IPV6_PRIVACY=no
IPADDR=192.168.175.100
GATEWAY=192.168.175.2
DNS1=192.168.175.2
3.改完之后重启网络
systemctl restart network
ping: www.baidu.com: 未知的名称或服务 发现依然ping不通外网
4.这是因为没有配置DNS解析服务导致的,添加DNS配置
cd /etc
vi resolv.conf
添加如下的配置
-------------------------------------------------------------------------------------------
search localdomain
nameserver 8.8.8.8
nameserver 8.8.4.4
5. 重启网络服务
systemctl restart network
再次ping百度,通了
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (39.156.66.18) 56(84) bytes of data.
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=1 ttl=128 time=8.38 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=2 ttl=128 time=7.71 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=3 ttl=128 time=8.21 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=4 ttl=128 time=8.09 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=5 ttl=128 time=7.97 ms