# Setting IP address in jail



## balanga (May 21, 2019)

Looking at examples for configuring jails, such as 





						FreeBSD Handbook
					

FreeBSD is an operating system used to power modern servers, desktops, and embedded platforms.




					www.freebsd.org
				



it shows `ip4.addr = [I]192.168.0.10[/I];                   # IP address of the jail`  whereas 


			VladimirKrstulja/Guides/Jails - FreeBSD Wiki
		

shows `ip4 = inherit;`...

What are the implications of either choice? And can't you use dhcp to set the address?


----------



## zirias@ (May 21, 2019)

Simple as that, in the second case, your jail will just use the host's address. In either case, the jail will use the host's network interface.

For dhcp, you need the jail to have its own network interface. This is possible as well, using the `vnet` option. you can for example configure an epair(4) interface and give the `b` end to the jail with `vnet.interface`. Of course, you will need to bring up the `a` end on the host and setup routing or put it in a bridge(4) for this to work.


----------



## balanga (May 31, 2019)

Zirias said:


> Simple as that, in the second case, your jail will just use the host's address. In either case, the jail will use the host's network interface.


If I have `ip4 = inherit;`, `jls` does not show an IP address, is this normal?
Also, I can't see where it gets its hostname from. /etc/jail.conf contains *host.hostname = "Sname"; * but the hostname shown when running `jls` it neither shows *11-1 * or the host's hostname, so where does it come from?


----------



## SirDice (May 31, 2019)

balanga said:


> If I have  ip4 = inherit;,  jls does not show an IP address, is this normal?




```
ip4     Control the availability of IPv4 addresses.  Possible values are
             "inherit" to allow unrestricted access to all system addresses,
             "new" to restrict addresses via ip4.addr, and "disable" to stop
             the jail from using IPv4 entirely.  Setting the ip4.addr
             parameter implies a value of "new".
```



balanga said:


> but the hostname shown when running  jls it neither shows *11-1 * or the host's hostname, so where does it come from?


Typo? Shouldn't that be $name? The $name refers to the name you gave the jail in jail.conf.


----------



## Lamia (May 31, 2019)

Choose a range of private IP addresses for your jails and configure pf to route traffic.


----------

