There are two physical NICs on the PC. The physical network card corresponding to eth0 in the virtual machine is connected to the TP-link router (192.168.1.1), and the physical network card corresponding to eth1 is connected to a local database (192.168.2.124 ).
(1) assign an address to this eth0:
# Ifconfig eth0 192.168.1.125 netmask 255.255.255.0
(2) Add a static route:
# Route add-net 192.168.1.0 netmask 255.255.255.255.0 Dev eth0
(3) Allocate an address to eth1:
# Route add-net 192.168.2.1 netmask 255.255.255.0
(4) add another static route:
# Route add-net 192.168.2.0 netmask 255.255.255.0 Dev eth1
(5) Add a default route for the system:
# Route add default GW 192.168.1.1 (TP-link address)
(6) Add the system's IP forwarding function:
# Echo 1>/proc/sys/NET/IPv4/ip_forward
At this point, the virtual machine Linux has basic vro functions. However, the problem is that the gateway can be pinged (eth1 of the Virtual Machine Linux), but the TP-link router cannot be pinged. Later, I found that the problem lies in my TP-link router: There is no static route for packet return, and there is no route for packets to be pinged out.
Solution: configure the TP-link router and set a static route (Destination: 192.168.2.0 GW: 192.168.1.125 ).
At this point, the vro can be accessed through the Virtual Machine Linux (you also need to set the LAN port of TP-link and set the subnet mask to 255.255.0.0; otherwise, you can only ping the vroping, but does not have the permission to log on to the vro ).
However, you cannot access the Internet because the network segment is 192.168.2.0, And the NAT rule of TP-link is only for the network segment 192.168.1.0. Therefore, we are going to re-configure the Virtual Machine Linux to enable its NAT Function.