# vnet and jail.conf solved



## teetotal (Oct 31, 2015)

I hated loosing connectivity so I spent a few days on this till it worked great. Just have your epairs pre-cloned in rc.conf.


```
# Generated by rc.d/jail at 2015-10-28 15:24:36
        host.hostname = "${name}";
        path = "/usr/jails/${name}";
        allow.raw_sockets = 1;
        exec.clean;
        exec.system_user = "root";
        exec.jail_user = "root";
        exec.consolelog = "/var/log/jail_${name}_console.log";
        mount.fstab = "/etc/fstab.${name}";
        mount.devfs;
        mount.fdescfs;
        mount.procfs;
        allow.mount;
        allow.set_hostname = 1;
        allow.sysvipc = 1;
        vnet;

data {
        vnet="new";
        vnet.interface =epair0b;
        exec.prestart  +="ifconfig bridge0 addm epair0a";
        exec.prestart  +="ifconfig epair0a up";
        exec.start +="ifconfig epair0b vnet ${name}";
        command ="/sbin/ifconfig epair0b inet 10.0.21.1";
        command +="route add -inet default 10.0.0.1";
        exec.start ="/bin/sh /etc/rc";
        exec.prestop +="ifconfig bridge0 deletem epair0a";
        exec.stop = "/bin/sh /etc/rc.shutdown";
        persist;
}
# Generated by rc.d/jail at 2015-10-28 15:24:36
www {
        vnet="new";
        vnet.interface =epair1b;
        exec.prestart  +="ifconfig bridge0 addm epair1a";
        exec.prestart  +="ifconfig epair1a up";
        exec.start +="ifconfig epair1b vnet ${name}";
        command ="/sbin/ifconfig epair1b inet 10.0.22.1";
        command +="route add -inet default 10.0.0.1";
        exec.start ="/bin/sh /etc/rc";
        exec.prestop +="ifconfig bridge0 deletem epair1a";
        exec.stop = "/bin/sh /etc/rc.shutdown";
        persist;
}
```


----------



## teetotal (Nov 12, 2015)

Adding ivp6 to a similar jail setup.

```
host.hostname = "${name}";
        path = "/usr/jails/${name}";
        allow.raw_sockets = 1;
        exec.clean;
        exec.system_user = "root";
        exec.jail_user = "root";
        exec.consolelog = "/var/log/jail_${name}_console.log";
        mount.fstab = "/etc/fstab.${name}";
        mount.devfs;
        mount.fdescfs;
        mount.procfs;
        allow.mount;
        allow.set_hostname = 1;
        allow.sysvipc = 1;
        #devfs_ruleset = "10";
        #enforce_statfs = 1;
        #allow.mount.devfs = 1;
        vnet;
data {
        vnet="new";
        vnet.interface =epair0b;
        exec.prestart  ="ifconfig bridge0 addm epair0a";
        exec.prestart  +="ifconfig epair0a up";
        exec.start ="ifconfig epair0b vnet ${name}";
        command ="ifconfig epair0b inet 192.168.0.30";
        command +="ifconfig epair0b inet6 2001:470:xx:xxx::4 prefixlen 64 alias";
        command +="route -n add -inet6 default 2001:470:xx:xxx:de0e:a1ff:fe16:504e";
        command +="route -n add default 192.168.0.1";
        exec.start ="/bin/sh /etc/rc";
        exec.prestop ="ifconfig bridge0 deletem epair0a";
        exec.stop += "/bin/sh /etc/rc.shutdown";
        persist;
}
env {
        vnet="new";
        vnet.interface =epair1b;
        exec.prestart  ="ifconfig bridge0 addm epair1a";
        exec.prestart  +="ifconfig epair1a up";
        exec.start ="ifconfig epair1b vnet ${name}";
        command ="ifconfig epair1b inet 192.168.0.31";
        command +="ifconfig epair1b inet6 2001:470:xx:xxx::5 prefixlen 64 alias";
        command +="route -n add -inet6 default 2001:470:xx:xxx:de0e:a1ff:fe16:504e";
        command +="route -n add default 192.168.0.1";
        exec.start ="/bin/sh /etc/rc";
        exec.prestop ="ifconfig bridge0 deletem epair1a";
        exec.stop = "/bin/sh /etc/rc.shutdown";
        persist;
}
```


----------



## paulfrottawa (Nov 30, 2018)

I have one problem at the moment creating epairs on boot. Can anyone help me with this. This command on a shell `ifconfig epair create`.

Solved but not finished 

```
cloned_interfaces="bridge0 epair0 epair1"

ifconfig_bridge0="addm vtnet "
```


----------

