[nzlug] Routing Tables

Michal Ludvig michal at logix.cz
Mon Jun 9 13:02:30 NZST 2008


Nevyn wrote:
> Hi,
> 
> I've been having a bit of a play with routing tables. Basically in my
> machine I have 2 ethernet devices - eth0 and eth1.
> 
> eth1 is a link to the internet. I don't really want eth1 to talk to
> this computer. Instead, I'm running a virtual machine on the computer
> and only really want it talking to the virtual machine.

Routing information can be cached in the kernel for some time and that 
may confuse your experiments.

For instance I'm on a host with two interfaces and want to access 
192.168.157.140. The route according to the current routing table goes 
via eth0:

~# /sbin/ip r get 192.168.157.140
192.168.157.140 via 192.168.158.1 dev eth0  src 192.168.158.18

Now I add a new route via a router on the other subnet and check the route:
~# /sbin/ip r add 192.168.157.140 via 192.168.130.210 dev eth1
~# /sbin/ip r get 192.168.157.140
192.168.157.140 via 192.168.130.210 dev eth1  src 192.168.130.122

That's all good. Now I delete the specific route again and check the cache:

~# /sbin/ip r del 192.168.157.140 via 192.168.130.210 dev eth1
~# /sbin/ip r get 192.168.157.140
192.168.157.140 via 192.168.130.210 dev eth1  src 192.168.130.122

See, it's still there. I have to flush the route cache table (or wait 
for the record to expire) to get back the default state:

~# /sbin/ip r flush table cache
~# /sbin/ip r get 192.168.157.140
192.168.157.140 via 192.168.158.17 dev eth0  src 192.168.158.18

Now it's back to default. Perhaps that's where the problem you observe lies.

Or give us more details of your VM environment. Is it VMware, Xen or 
something else? Do you have an eth-bridge set up with both the VM and 
the host connected to it?

M.



More information about the NZLUG mailing list