diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-07-25 00:09:01 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-09-26 16:14:53 +0200 |
| commit | cc1b02f99e457d2a5a440698e9bae1ca30f408e1 (patch) | |
| tree | d26b3086697996b27f9e459cadcf195adc60eebb /templates/etc_jail.conf.j2 | |
| parent | d1c9aa40ccb5910076d0ec94843efccf62ee006a (diff) | |
Initial impl of vnet jails
Diffstat (limited to 'templates/etc_jail.conf.j2')
| -rw-r--r-- | templates/etc_jail.conf.j2 | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/templates/etc_jail.conf.j2 b/templates/etc_jail.conf.j2 index bcfcef0..86da8de 100644 --- a/templates/etc_jail.conf.j2 +++ b/templates/etc_jail.conf.j2 @@ -1,7 +1,19 @@ -# STARTUP/LOGGING -exec.start = "/bin/sh /etc/rc"; -exec.stop = "/bin/sh /etc/rc.shutdown"; -exec.consolelog = "/var/log/jail_console_${name}.log"; +# STARTUP/LOGGING/VNET +$epair = "epair${num}"; # epairXa is host end, epairXb is jail end +vnet; +vnet.interface = "${epair}b"; +persist; +exec.prestart += "ifconfig $epair create || echo 'Failed to create $epair'"; +exec.prestart += "ifconfig ${epair}a up"; +exec.prestart += "ifconfig bridge0 addm ${epair}a"; +exec.clean; +exec.start = "/bin/sh /etc/rc"; +exec.poststart = "jexec ${name} ifconfig ${epair}b 192.168.2.${num}/16"; +exec.poststart += "jexec ${name} route add default 192.168.0.1 || echo 'Failed to add default route'"; +exec.stop = "/bin/sh /etc/rc.shutdown"; +exec.poststop += "ifconfig ${epair}b -vnet $name"; # workaround to bug 238326: move ${epair}b from the jail to the host when stopping jail services +exec.poststop += "ifconfig ${epair}b destroy"; # and then destroy the pair by destroying one end of it +exec.consolelog = "/var/log/jail_console_${name}.log"; # PERMISSIONS allow.raw_sockets; @@ -15,8 +27,7 @@ path = "/usr/local/jails/containers/${name}"; # JAILS {% for jail in jails %} {{ jail.name }} { - ip4.addr = {{ jail.ip }}; - interface = lan0; + $num = "{{ jail.num }}"; } {% endfor %} |
