# VIMAGE jails and Routing



## hederaleaf (Aug 14, 2017)

In accordance with the VIMAGE: Setup Guide, I have set up a FreeBSD 11.1 server on a VPS with the following configuration:

/usr/local/kernels/VIMAGE

```
include GENERIC
ident VIMAGE

options VIMAGE
device epair
device if_bridge
```

/etc/rc.conf

```
cloned_interfaces="bridge0"
ifconfig_vtnet0="inet xxx.xxx.xxx.205 netmask 255.255.255.0"
ifconfig_bridge0="addm vtnet0"
defaultrouter="xxx.xxx.xxx.1"
jail_enable="YES"
```

/etc/sysctl.conf

```
net.inet.ip.forwarding=1
net.link.bridge.pfil_onlyip=0
net.link.bridge.pfil_bridge=0
net.link.bridge.pfil_member=0
net.add_addr_allfibs=0
```

/etc/jail.conf

```
allow.mount;
allow.raw_sockets   =  "1";
allow.set_hostname  =  "0";
allow.sysvipc       =  "1";

host.hostname  =  "${name}.diacritical.net";
path           =  "/mnt/jails/${name}";

mount.fstab  =  "/etc/fstab.${name}";
mount.devfs;
mount.fdescfs;
mount.procfs;
devfs_ruleset  =  "4";

exec.clean;
exec.start +=  "/bin/sh /etc/rc";
exec.stop   =  "/bin/sh /etc/rc.shutdown";

test {
  $if                 = "0";
  $ip_addr            = "10.0.0.8";
  $ip_route           = "xxx.xxx.xxx.1";
  vnet;
  vnet.interface      = "epair${if}b";
  exec.prestart       = "ifconfig epair${if} create up";
  exec.prestart      += "ifconfig bridge0 addm epair${if}a";
  exec.start          = "/sbin/ifconfig epair${if}b inet ${ip_addr} up";
  exec.start         += "/sbin/route add default -gateway ${ip_route}";
  exec.start         += "/bin/sh /etc/rc";
  exec.stop           = "/bin/sh /etc/rc.shutdown";
  exec.poststop       = "ifconfig epair${if}a destroy";
  persist;
}
```

When the server attempts to write the routing socket for the jail on startup, I get the following error:


```
test: created
route: writing to routing socket: Network is unreachable
add net default: gateway xxx.xxx.xxx.1 fib 0: Network is unreachable
jail: test: /sbin/route add default -gateway xxx.xxx.xxx.1: failed
test: removed
```

The public IP address of this server is denoted as:

```
xxx.xxx.xxx.205
```

The gateway of this server is denoted as


```
xxx.xxx.xxx.1
```

Any help at all is appreciated!


----------

