Subject: Re: [vserver] Mounting NFS(v4) with vserver guest's own IP address
From: Mark Hunting <mark@netexpo.nl>
Date: Thu, 31 Jan 2008 14:23:11 +0100

Mark Hunting wrote:
> Martin Fick wrote:
>   
>> --- Mark Hunting <mark@netexpo.nl> wrote:
>>   
>>     
>>> Herbert Poetzl wrote:
>>>     
>>>       
>>>> On Sun, Jan 27, 2008 at 11:34:17AM +0100, Mark
>>>>       
>>>>         
>>> Hunting wrote:
>>>     
>>>       
>>>> sure, make sure that multiple routing tables are
>>>>       
>>>>         
>>> enabled,
>>>     
>>>       
>>>> assign one to your guest, and setup proper routing
>>>> (source based) there, and the kernel will honor
>>>>       
>>>>         
>>> that
>>>     
>>>       
>>>>   
>>>>       
>>>>         
>>> That sounds great. But how do I assign a specific
>>> routing table to a
>>> guest? 
>>>     
>>>       
>> You can find some good source routing info in the
>> Advanced Linux Routing How-To here:
>>
>> http://lartc.org/howto/lartc.rpdb.html
>>
>> -Martin
>>     
> Thanks. I've played with the routing tables now, but it just won't work.
> Can you guys give me a hint? The IP address of the host is 192.168.4.6
> (eth1), the IP of the guest is 192.168.4.38. I did this:
>
> echo 200 test >> /etc/iproute2/rt_tables
> ip rule add from 192.168.4.38 table test
> ip route add default src 192.168.4.38 dev eth1 table test
> ip route flush cache
>
> Unfortunately my NFS actions on the guest keep coming from 192.168.4.6
> instead of 192.168.4.38. I guess the 'local' table does have something
> to do with this:
>
> #ip route list table local
> local 87.255.48.38 dev eth0  proto kernel  scope host  src 87.255.48.6
> broadcast 192.168.4.255 dev eth1  proto kernel  scope link  src 192.168.4.6
> local 87.255.48.6 dev eth0  proto kernel  scope host  src 87.255.48.6
> broadcast 127.255.255.255 dev lo  proto kernel  scope link  src 127.0.0.1
> local 87.255.48.37 dev eth0  proto kernel  scope host  src 87.255.48.6
> broadcast 87.255.48.127 dev eth0  proto kernel  scope link  src 87.255.48.6
> local 192.168.4.39 dev eth1  proto kernel  scope host  src 192.168.4.6
> local 192.168.4.6 dev eth1  proto kernel  scope host  src 192.168.4.6
> broadcast 127.0.0.0 dev lo  proto kernel  scope link  src 127.0.0.1
> local 192.168.4.38 dev eth1  proto kernel  scope host  src 192.168.4.6
> local 127.0.0.1 dev lo  proto kernel  scope host  src 127.0.0.1
> local 127.0.0.0/8 dev lo  proto kernel  scope host  src 127.0.0.1
>
> Herbert wrote that this is not something VServer specific, but I hope
> somebody can help me. When this works I will certainly add it to the
> VServer wiki. I guess this is a problem for more people working with
> VServers and NFS (and who, like me, don't know all ins and outs of
> routing tables).
>
> Mark
>   
Well I think I have set up my routing correct now, but NFS is still
using the host's IP address. I think this is because all NFS actions are
handled by the kernel. The kernel uses the host's IP address by default.
Apparently NFS in the kernel can only 'know' of one IP address, you
can't make NFS actions on one mount go via address X and actions on
another mount via address Y. I can route all 192.168.4.x traffic through
192.168.4.39, but that is server-wide then. So maybe there is no
solution to this problem at all...