1. First configure the static IP. You need to remove the dynamic IP allocation.
2. The third network segment of the subnet must be different from the host network segment. The third network segment of the host IP in this article is: 1, and the third network segment of the virtual machine is set to: 239
Related learning Video tutorial sharing:linux video tutorial
3, NET settings
##4, ifcfg-ens33 file configuration.cd /etc/sysconfig/network-scripts vim ifcfg-ens33
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 DEVICE=ens33 PREFIX=16 ### UUID默认 UUID=4d1c2382-814d-45e1-a5b9-252086ceff86 ### 此部分设置最重要 需要根据实际情况进行设置。 # BOOTPROTO IP的配置方法[none|static|bootp|dhcp](引导时不使用协议|静态分配IP|BOOTP协议|DHCP协议) BOOTPROTO=static # ONBOOT 系统启动的时候网络接口是否有效(yes/no) ONBOOT=yes IPADDR=192.168.239.128 # 前边三个网段根据虚拟机设置进行配置 192.168.239.xxx 最后的xxx在0-255之间即可 GATEWAY=192.168.239.2 # 网关很重要,根据虚拟机设置的网关进行配置 DNS1=8.8.8.8 # DNS必填,否则可能无法上网 DNS2=114.114.114.114
service network restart
The above is the detailed content of Solution to Linux unable to access external network. For more information, please follow other related articles on the PHP Chinese website!