Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of being unable to access the external network after CentOS network configuration

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to solve the problem of being unable to access the external network after CentOS network configuration". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Phenomenon:

The private network of ping is normal.

Ping public network IP, domain names are not working properly. Error returned: connect: Network is unreachable

Later, I inadvertently saw that the Linux network was configured with the command to add a gateway:

The code is as follows:

Route add default gw 192.168.128.2 dev eth0

Do as above, after adding the default gateway. Everything is fine when you visit the public network again.

From this point of view, the gateway should not be configured in the configuration file, but it is confirmed that the GATEWAY address is configured in / etc/sysconfig/network, and the GATEWAY address is also correct. After restarting network many times, as long as you do not manually add the gateway, you cannot access the public network.

After carefully confirming each network configuration file many times, it is found that there is a NETWORK configuration item in the network card configuration file (ifcfg-eth0). The function of this configuration item is not very clear, so I went to the official website to check the instructions:

The code is as follows:

NETWORK=

Where is the network address. This directive is deprecated, as the value is calculated automatically with ifcalc.

This rhythm tells us that this parameter should not be set (deprecate). This value will be calculated automatically by ifcalc. Since there is no need to set it, it will be removed naturally.

After removing it and restarting the network service, the public network is miraculously able to access it. Use route to check the routing table and find that the message default can be added automatically, but it has not been available all the time:

The code is as follows:

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

192.168.128.0 * 255.255.255.0 U 000 eth0

Link-local * 255.255.0.0 U 1002 00 eth0

Default 192.168.128.2 0.0.0.0 UG 0 0 0 eth0

It seems that the problem is caused by this NETWORK parameter setting. As for the exact reason for this, it is not clear what impact this setting will have.

TIPs: for simplicity, you can also set IPADDR,GATEWAY and so on to the file of ifcfg-eth*, instead of setting GATEWAY in network separately.

This is the end of the content of "how to solve the problem of being unable to access the external network after CentOS network configuration". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report