# Help with jails



## balanga (Apr 19, 2019)

I've never used jails before, except under FreeNAS, so setting one up seems like a bit of a learning curve...

If I want to install pkgs I need Internet access but how do I address the host's NIC? Can I expect to run `dhclient em0`? - Just tried, apparently not - I get `em0: not found`


----------



## SirDice (Apr 19, 2019)

A standard jail is attached to an interface and is assigned an IP address from the host. Network configuration is done from the host, you can't change it from inside the jail. A VNET jail has its own interface and can configure its network config from inside the jail. If I recall correctly FreeNAS uses VNET jails. 

Handbook: Chapter 14. Jails


----------



## balanga (Apr 19, 2019)

After looking at The Handbook, I'm still unclear as to how to setup an IP address...

`jls` shows that I have set an IP address of 192.168.0.17 but if I ping it I get no response.

Obviously missing something here...


----------



## SirDice (Apr 19, 2019)

Note that you cannot ping from inside the jail, you'll need to enable `raw_sockets` for that. 



balanga said:


> jls shows that I have set an IP address of 192.168.0.17 but if I ping it I get no response.


Post the relevant bits from jail.conf.


----------



## balanga (Apr 19, 2019)

```
11-0 {
<------>path = /usr/jail/11.0;
<------>mount.devfs;
<------>host.hostname ="11.0";
<------>ip4.addr = 192.168.0.17;
<------>exec.start = "/bin/sh /etc/rc";
<------>exec.stop = "/bin/sh /etc/rc.shutdown";
}
```

The host is 192.168.0.36

`jls`:-
`JID  IP Address      Hostname                      Path
     5  192.168.0.17    11.0                          /usr/jail/11.0`


----------



## SirDice (Apr 19, 2019)

It's not bound to an interface. Add an `interface` and bind the jail to the host's interface.

Example:

```
ports {
    host.hostname = "ports.dicelan.home";
    ip4.addr = 192.168.10.202;
    interface = em0;

    path = /jails/j-ports/;
    mount.fstab = /etc/fstab.$name;
}
```


```
root@molly:~ # jls
   JID  IP Address      Hostname                      Path
     1  192.168.10.202  j-ports.dicelan.home          /jails/j-ports
```
The host's em0 interface is in the same 192.168.10.0/24 network. 

NB. Be careful with periods in a hostname. Remember that periods have a special meaning in hostnames and domains. Your hostname is now '11' and it has '0' as a TLD.


----------

