Need different routing table on host and jail

... which is impossible afaik, so I'm asking here in case someone has a clever solution.

Background: I have 2 internet connections, one from my cable company(A) and another from an adsl provider(B).
A is the preferred connection for all traffic, but the cable provider blocks SMTP on their net.

To work around that I was thinking of putting postfix in a jail and let that 'server' use B exclusively, but no matter how I look at
it I can't see how to do it unless I have separate default routes?

Do I really need a physical box to do this or can it be done with a jail?
 
Slightly embarrassing, but I was totally ignorant of setfib(1) and the possibility of per-process routing tables. Apparently it's been in FreeBSD since 7.1.

Not only that, taking a second look at /etc/defaults/rc.conf I find this

Code:
#jail_example_fib="0"                           # Routing table for setfib(1)

So support is right there and ready to use. To put it into action here's what to do.

Recompile kernel with an extra option

Code:
options         ROUTETABLES=4           # default is 1, max 16.

add to /etc/rc.conf

Code:
jail_mail_fib=1

and to /etc/rc.d/jail

Code:
start_precmd="setfib 1 route add default a.b.c.d"
stop_postcmd="setfib 1 route delete default a.b.c.d"

[that last one is an ugly hack that should be redone more properly]
 
Back
Top