To clarify my question...
I am wondering how does the Linux kernel route packets on a multi-home host?
With 'multi-home', I mean the host has multiple NICs to send packets, for example my Debian in Virtualbox has two NICs.
eth0 provides the NAT support. I don't know how Virtualbox manages to do that. I mean there isn't any virtual NIC in my windows host whose IP is 10.0.2.x.
eth1 provides the host-only support. I use this small network to learn TCP/IP protocol and do some small experiments. I manually configure it to IP address 192.168.56.2, gateway 192.168.56.1, the latter IP address is the Virtualbox virtual NIC IP address.
host operating system I use ADSL to connect to the Internet and get a random IP address, e.g.118.249.xxx.113.
So the question comes out, how does the linux kernel route IP packets? I mean if I have run the following commands, I am not able to connect to the Internet.
that ping would return no response.
So is it that the after setting up the eth1, the kernel would use eth1 as the default NIC, which is in the host-only network, to send IP packets? As a result, in Debian, I cannot connect to the outside internet?
Another simple question is, as eth1 now is the default NIC, will the Linux kernel try to use the eth1 NIC to send packets if eth0 has failed to find an available route entry?
If it will, then how to configure it?
Here is my network configuration of Debian Linux in Virtualbox.
eth0 Link encap:Ethernet HWaddr 08:00:27:ec:d9:bb inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:feec:d9bb/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1690 errors:2 dropped:0 overruns:0 frame:0 TX packets:1129 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2276172 (2.1 MiB) TX bytes:62647 (61.1 KiB) Interrupt:11 Base address:0xd020 eth1 Link encap:Ethernet HWaddr 08:00:27:ae:e1:69 inet addr:192.168.56.2 Bcast:192.168.56.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:feae:e169/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:48 errors:0 dropped:0 overruns:0 frame:0 TX packets:17 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:5985 (5.8 KiB) TX bytes:1334 (1.3 KiB) Interrupt:10 Base address:0xd240 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:560 (560.0 B) TX bytes:560 (560.0 B)
and the route table follows:
Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 0.0.0.0 192.168.56.1 0.0.0.0 UG 0 0 0 eth1 0.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 eth0