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 realize Network Fault diagnosis under Linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article will explain in detail how to achieve network fault diagnosis under Linux. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Network card failure can be divided into hardware failure and software fault, the easiest way to judge hardware failure is to plug the network card into other computers, if it is still old fault, the network card is damaged, otherwise the network card is normal. In fact, most of the network card failures belong to software faults, which are generally divided into two categories: one is setting fault, the other is driver fault.

Diagnose the fault of the network card

[root@localhost ~] # dmesg | grep etheth0:registered as PCnet/PCI II 79C970Aeth0:link upeth0:no IPv6 routers present [root@localhost ~] #

The above command lists the lines that contain the eth string in the boot information, and if a prompt similar to "eth0:link up" appears, it means that Linux has detected the network card and is working properly. There is also a lspci command that lists all PCI devices detected by the system. If the network card used is PCI bus, you should be able to see the information about this network card. Finally, you can use ethtool to see if the Ethernet link is connected properly.

The above command lists the lines that contain the eth string in the boot information, and if a prompt similar to "eth0:link up" appears, it means that Linux has detected the network card and is working properly. There is also a lspci command that lists all PCI devices detected by the system. If the network card used is PCI bus, you should be able to see the information about this network card. Finally, you can use ethtool to see if the Ethernet link is connected properly.

[root@localhost ~] # ethtool eth0Settings for eth0: Current message level: 0x00000007 (7) Link detected:yes [root@localhost ~] #

If you see the line "Link detected:yes", it indicates that the network card is also connected to the other party's network line is normal.

Network card driver

In RHEL 6, you need to first view or set up the / etc/modeprobe.cong file, which contains information about module installation and aliases.

[root@localhost ~] # more / etc/modeprobe.cong alias scsi_hostadapter mptbase... Alias eth0 pcnet32 [root@localhost ~] #

In the above display, the last line "alias eth0 pcnet32" indicates that an alias eth0 is defined for pcnet32, that is, the module corresponding to the currently used Ethernet card interface eth0 is pcnet32, and you can use to command whether there is a pcnet32 module in the module loaded by the current system.

[root@localhost 2.6.18-8.e15] # lsmod | grep pcnet32pcnet32 35269 0mii 9409 1 pcnet32 [root@localhost 2.6.18-8.e15] #

You can see that pcnet32 is already installed. Therefore, if the network card has been detected by Linux, but the eth0 interface is not seen when executing the "ipconfig-a" command, you can follow the above method to find the driver module of the network card and see if the module has been installed.

Diagnose problems at the network layer

The diagnosis method of the network layer problem is very simple, that is, directly ping a domain name or IP of the public network. If it can be connected normally, it means that there is no problem at the network layer.

There are many reasons for the differences in ping, such as network wiring, network settings, routing, and ARP. It is recommended to ping the gateway first to see if it can be connected. If it can be connected to the gateway, it generally indicates that there is nothing wrong with the network line, the network settings of your computer and the ARP. You can display the routing table with the command "route-n" and then get the address of the gateway. If the default gateway is not set in the routing table, there is a problem with the routing settings, and the default gateway needs to be set at this point.

Sometimes, there are ARP attacks or other reasons in the local area network, so that the MAC address of the gateway IP in the native ARP cache is wrong, which can also cause disconnection with the gateway ping. At this point, you can use the "arp-d" command to delete the ARP entry for the gateway, or use the "arp-a" command to set the static ARP entry.

Diagnose problems at the transport layer and application layer

One of the most effective means to diagnose the faults of the transport layer and the application layer is to use the packet grabbing tool to grab the packet for analysis. In Linux, the tcpdump tool is provided by default, which allows you to crawl all packets that visit or leave the machine, and only those packets of interest can be crawled through rules.

One possible cause of failure related to the operating system is the improper configuration of the firewall. In Linux, iptables Firewall is enabled by default when the system boots, and only a few ports are released. Therefore, when a service is configured on the local machine, and this service needs to be accessed through a port of TCP or UDP, the firewall is required to open the corresponding port, otherwise, other hosts will not be able to access this service of the local machine.

This is the end of the article on "how to realize network fault diagnosis under Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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