Locating VM Network Faults
Symptom
The VM network connection is abnormal.
Key Process and Cause Analysis
Locating faults in the VM network connection takes multiple steps. You need to systematically check all aspects of network configuration.
Conclusion and Solution
Perform the following steps to systematically locate faults in the VM network connection. The steps include checking basic network configurations and system parameters, and capturing packets.
- Check the internal network configuration of the VM.
Check the IP address, gateway, and subnet mask carefully to ensure that they are correctly configured and there are no network segment conflicts.
- Check the firewall and iptables rules.
Firewall and iptables rules may block network communication.
- After the firewall is enabled or disabled, run the following command to restart the libvirtd service for the modification to take effect:
systemctl restart libvirtd.service
- If Docker also runs on the host, you may need to add specific iptables rules to ensure normal network communication between the VM and Docker containers in the shared scenario. For example, add the following iptables rules to allow traffic forwarding in the virbr0 bridge:
iptables -I FORWARD -i virbr0 -o virbr0 -j ACCEPT
- After the firewall is enabled or disabled, run the following command to restart the libvirtd service for the modification to take effect:
- Check system parameters.
- Check the ip_forward configuration, that is, check whether the net.ipv4.ip_forward parameter is enabled. If the value is 1, the parameter is enabled.
sysctl -a|grep ip_forward
- Enable ip_forward.
- Check the ip_forward configuration, that is, check whether the net.ipv4.ip_forward parameter is enabled. If the value is 1, the parameter is enabled.
- Perform special configurations for OVS + DPDK.
If OVS and DPDK are used, configure huge page memory and enable shared memory. The following is an example of the VM XML configuration file content:
<memoryBacking> <hugepages> <pagesize unit="KiB">1048576</pagesize> </hugepages> </memoryBacking> ...... <cpu mode="host-passthrough" check="none"> <topology sockets="1" dies="1" clusters="1" cores="8" threads="1"/> <numa> <cell id="0" cpus="0-7" memory="33554432" unit="KiB" memAccess="shared"/> </numa> </cpu> - Use the tcpdump tool to capture packets and locate faults.
Use the ping command to check the transmission path of ICMP packets on the network and locate network faults.
- Run the ping command to check the network connectivity.
The ping command is an effective tool to determine network problems preliminarily. It can be used together with a packet capturing tool to determine which network layer is faulty.
- Install the tcpdump tool to capture and analyze network data packets.
yum install tcpdump
- Listen to ICMP packets on a specific interface to help locate faults.
tcpdump -i eth0 icmp
- Run the ping command to check the network connectivity.
- Check the VLAN configuration.
- If a VLAN needs to be configured, ensure that the connected switch has been correctly configured and allows packets from the VLAN to pass through.
- VLANs must be correctly configured for the NICs of the VM.