" background ": Configure Ubuntu Virtual machine Dual network card, one is Host-only network, one is Bridge network. When the virtual machine is connected to two networks at the same time, the virtual machine can ping the internal network, not ping the external network, such as www.baidu.com.
1. Virtual Machine NIC Configuration
2. Virtual Machine Internal network configuration
Hostonly Network configuration:
Bridging Network configuration:
3. Check the virtual machine network
Ping does not pass the extranet, view the routing table.
Failure reason: found that the default route is Hostonly network, the network segment is 56 segments, cannot communicate with the external network, the default route is modified to 1 segments (192.168.1.X).
4. Modifying the default route
dev@dev-virtualbox:~$sudoRoute add default GW192.168.1.1Dev@dev-virtualbox:~$ routekernel IP routing tabledestination Gateway genmask Flags Metric Ref use Ifacedefault 192.168.1.1 0.0.0.0Ug0 0 0Eth1default192.168.56.1 0.0.0.0Ug0 0 0eth0192.168.1.0*255.255.255.0U1 0 0eth1192.168.56.0*255.255.255.0U1 0 0Eth0
The modification found that there were two default routes, and then DNS appeared, and the domain name resolution could not be performed.
Solution:
Delete the default route for a 56 network segment
dev@dev-virtualbox:~$sudoRoute del default GW192.168.56.1Dev@dev-virtualbox:~$ routekernel IP routing tabledestination Gateway genmask Flags Metric Ref use Ifacedefault 192.168.1.1 0.0.0.0Ug0 0 0eth1192.168.1.0*255.255.255.0U1 0 0eth1192.168.56.0*255.255.255.0U1 0 0Eth0
There is also a relatively simple scenario, when creating a virtual machine NIC, set the virtual machine network card sequence is: Network card 1 bridge network, network card 2HostOnly.
"Ubuntu Everyday Skills" VirtualBox multi-NIC routing configuration to ensure virtual Machine connection Sisu Network