I'll assume this is starting from scratch so I'll just try to explain it all. If you've used the Linux implementation of multiple routing tables before keep in mind that it's done a little bit differently in FreeBSD. The biggest difference here is that FreeBSD doesn't have the same underlying concept of sending from address x.x.x.x to destination y.y.y.y. Instead it's processes that must be explicitly bound to the FIB that you want them to run on. If you want the same service on multiple FIBs then multiple instances of the same service must be run.
Set 2 routing tables. You'll need to reboot after setting this tunable. You can set up the next three items and reboot afterwards.
echo 'net.fibs=2' >> /boot/loader.conf
In this case, prevent device routes being added by default as you have found.
echo 'net.add_addr_allfibs=0' >> /boot/loader.conf
Then you'll need to assign the gateway for FIB 1 in
/etc/rc.conf.
Code:
static_routes="fib1default"
route_fib1default="default 192.168.18.1 -fib 1"
For an initial test of the configuration, you can do some quick ping checks. I'm assuming the gateway is 192.168.18.2 in my examples and I am assuming will be the same for both FIBs. You can test this with:
ping 192.168.18.2 (
setfib 0 is implied so you don't need to type it)
and
setfib 1 pint 192.168.18.2.
If you have a packet capture running on that device you should see the ping requests and replies on the appropriate interface. You should be ready to move on to configuring a service or jail to actually use the FIB now.
For a service, set the service you want to use that FIB to use it in
/etc/rc.conf. As an example.
For a jail, you'll have to consult the man page for either
jail.conf(5) or whatever utility you are using to help configure your jails.