Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to solve the problem that linux cannot access the external network

Shulou Source: shulou.com Published: 2022-06-03 03:56:17 09月22日 Update

1. First configure static ip. Dynamic ip allocation needs to be removed.

2. The third IP address range of the subnet should be different from that of the host. In this paper, the third network segment of the host IP is: 1, and the third network segment of the virtual machine is set to: 239

3. NET settings

4. Ifcfg-ens33 file configuration.

Cd / etc/sysconfig/network-scriptsvim ifcfg-ens33TYPE=EthernetPROXY_METHOD=noneBROWSER_ONLY=noDEFROUTE=yesPEERDNS=yesPEERROUTES=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_PEERDNS=yesIPV6_PEERROUTES=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=ens33DEVICE=ens33PREFIX=16 # UUID default UUID=4d1c2382-814d-45e1-a5b9-252086ceff86 # this part of the setting is the most important need to be set according to the actual situation. # configuration method of BOOTPROTO IP [none | static | bootp | dhcp] (do not use protocol when booting | static assign IP | BOOTP protocol | DHCP protocol) whether the network interface is valid when the BOOTPROTO=static# ONBOOT system starts (yes/no) ONBOOT=yesIPADDR=192.168.239.128 # the first three network segments are configured according to the virtual machine settings. 192.168.239.xxx the last xxx is between 0-255. it's important that the gateway Configure DNS1=8.8.8.8 # DNS according to the gateway set by the virtual machine, otherwise you may not be able to access the DNS2=114.114.114.114

5. Restart the network service

Service network restart

These are the details of the solution that linux cannot access the public network. Please pay attention to other related articles for more information.

Tags: Network segment configuration three important host host method gateway network static allocation different effective between content dynamic actual that is situation interface Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Apple OPPO Reno macOS NVidia