jails How to configure routing for jail?

ikevin8me

Active Member

Reaction score: 12
Messages: 198

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 172.16.0.1" 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?
 

cmoerz

Member

Reaction score: 37
Messages: 98

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 ...";
 

im

Active Member

Reaction score: 46
Messages: 109

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.
jail()
Code:
exec.fib
The FIB (routing table) to set when running commands inside the jail.

I have used that scheme decade ago.
 
Top