# Need different routing table on host and jail



## jalla (Jun 16, 2010)

... 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?


----------



## DutchDaemon (Jun 16, 2010)

setfib(1)/setfib(2) to launch Postfix with its own network view? Or maybe even the route-to statement in pf.conf(5) to route outbound smtp traffic to the 'dsl provider' interface?


----------



## jalla (Jun 17, 2010)

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


```
#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


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

add to /etc/rc.conf


```
jail_mail_fib=1
```

and to /etc/rc.d/jail


```
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]


----------

