static routes in rc.conf and jails

Hi,

I have a system with jails. The jails are started on system bootup and everything is configured in rc.conf. Whenever the system boots up, the jails are first created, the virtual interfaces are created and placed in the jails (with VIMAGE), everything is given IP addresses and routes of the jails are added.

The routes force some traffic to use one of the jail's interfaces to pass through it. Everything works fine except that it only does manually. I wish to do this all via rc.conf so that I don't have to do anything once the system boots up.

One of the steps requires me to have a default router on the host system as well as a route to the jail's network. I added these lines to my rc.conf
Code:
static_routes="net1"
route_net1="-net 4.0.0.0/8 10.0.0.1"
defaultrouter="1.1.1.2"

1.1.1.2 is a physical interface
10.0.0.1 is on the jail
4.0.0.0 is a different network.

now my problem with the static route. It appears that no matter where I place these lines in rc.conf (I tried to place them after I have created the jails), they still execute before any of the jail commands are executed. So basically, rc.conf tries to add 4.0.0.0/8 10.0.0.1 but 10.0.0.1 is not created yet.

How can I work around this?


Is there a way to change the order at which modules are loaded in order to force the jail daemon to start before the network? and if so, are there any consequences to this?
 
beaute said:
How can I work around this?


Is there a way to change the order at which modules are loaded in order to force the jail daemon to start before the network? and if so, are there any consequences to this?
Might be a catch-22 with starting the jail before the network, but you're welcome to experiment by editing /etc/rc.d/routing and adding "jail" to the end of the "# REQUIRE" line.

Otherwise remove the jail specific routes and use jail_X_exec_poststartN directives that execute /sbin/route. From rc.conf(5):

Code:
jail_<jname>_exec_poststart<N>
             (str) Unset by default.  This is the command run as Nth com-
             mand after jail startup, where N is 0, 1, and so on.  It is
             run outside the jail.
 
Back
Top