-   Linux - Networking (
-   -   RT_Tables and VRF simulation inside host (

highland7 11-14-2012 01:46 PM

RT_Tables and VRF simulation inside host
I use software to simulate routers, that software creates two interfaces in system for each of two interfaces of the router.
That interfaces are routed interfaces via which i can communicate with simulated router.
Lets call that interfaces:
netio0 - linux ip address, router:
netio1 - linux ip address, router:

i wanted to send packet thru that router, but normally of course when i send packet from to it would never be send via any of interfaces because these are locally configured interfaces (or the response problem even for static routing entries) So i used:

echo 1 VRF1 >> /etc/iproute2/rt_tables
echo 2 VRF2 >> /etc/iproute2/rt_tables
ip route add default via dev netio0 table VRF1
ip route add default via dev netio1 table VRF2

And created rules which for the traffic from one side to another use specific RT_Table:
ip rule add from table VRF1
ip rule add from table VRF2

And it works, but only partially.
Traffic from to (other interface of router) works fine.
Traffic from to is sent through router and i can sniff it on other side (netio1), but linux system never respond to that traffic.

It looks like linux kernel limitation to me: it will discard the packet from one of it's interfaces to another.
Could you confirm ?

Do you have any way to simulate VRFs on Linux ? I need independent routing tables which are really separated (like on cisco/juniper routers which are based on ...linux).


nini09 11-19-2012 03:29 PM

You need to use VLAN interface plus ip tool to simulate VRF.

highland7 11-20-2012 03:08 AM

As you see i am using ip tool to simulate VRF and it's working for me but with some limitations.
"VLAN interface " - do you mean 802.1q ?
adding 802.1q would not change anything, still i would need to accept and respond to packet from other logical interface (instead of physical interface) - and in fact i already use logical (not physical interfaces).

nini09 11-20-2012 02:08 PM

My point is that the traffic can send out but system doesn't respond the incoming traffic because the VLAN isn't used.

highland7 11-21-2012 12:01 AM

but why whould it respond if VLAN is used ?
It's just another interface. Right now it's also in another interface (netio interface).
And just to clarify: speaking VLAN you mean 802.1q ?


nini09 11-26-2012 02:36 PM

Yes, VLAN is 802.1q.
For IP rule, I think you should use iff instead of from. Please execute "ip route list VRF2" and "ip rule show".

ip rule add from table VRF1
ip rule add from table VRF2

Should be
ip rule add iif netio0 table VRF1
ip rule add iif netio1 table VRF2

All times are GMT -5. The time now is 11:31 AM.