To run multiple jails on a single host and provide different routing tables (FIBs) to each jail, you have to compile a custom kernel.
Update: Compiling a custom kernel is no longer needed with FreeBSD 12. Start at step 4 for the same results.
In this example, we will recompile the kernel to provide 15 additional FIBs.
- Create a new kernel file:
mkdir -p /root/kernels touch /root/kernels/ROUTING cd /usr/src/sys/amd64/conf ln -s /root/kernels/ROUTING
- Edit the new kernel config file (
vim /root/kernels/ROUTING
). In this example, we're adding the option for additional FIBs while regerencing the GENERIC kernel settings for the rest:include GENERIC ident ROUTING options ROUTETABLES=16
- Compile:
cd /usr/src make -j20 buildkernel KERNCONF=MYKERNEL make installkernel KERNCONF=MYKERNEL
- Update the boot loader config
vim /boot/loader.conf.local
:net.fibs="16"
- Update the sysctl config
vim /etc/sysctl.conf
:net.add_addr_allfibs="0"
- Reboot
Here's how to keep the custom kernel up-to-date.
Update: 2018-08-18: Fixed errors in step 1.