jails How to configure routing for jail?


Active Member

Reaction score: 12
Messages: 179

I'm having some problem setting routing inside a jail.
I added to rc.conf (inside jail) and it did not work.
I then tried "route add" and it responded "route: writing to routing socket: Operation not permitted"

I think it is not possible to set routing from inside.

So, how do I configure routing (set gateway) for a jail from the host?



Reaction score: 15
Messages: 44

You're right. A regular jail does not have its own routing table, as far as I remember. It basically picks up that info from the host. You may be able to make some routing work if you're using vnet based jails but even then, any routing setup would usually be done during jail setup from the host side, not from the jail side.

Are you using a plain vanilla jail? If so, you could expand your /etc/jails.conf to include something like
exec.start += "/sbin/route add ...";


Active Member

Reaction score: 44
Messages: 108

As far as I know, you can setup a second routing table using setfib().
Also you can assign that FIB to the jail using exec.fib param.
The FIB (routing table) to set when running commands inside the jail.

I have used that scheme decade ago.