# No networking upon starting jails without rebooting



## andrewm659 (Jul 28, 2015)

It seems that whenever I create a new jail w/with sysutils/ezjail the only way I can get it to communicate w/with the network or DNS is to completely restart the computer.  Am I doing something wrong?

Restarting the service doesn't help either...

Running FreeBSD 10.1


----------



## junovitch@ (Jul 29, 2015)

Can you either show what command line you used to make the jail or provide the configuration line with the IP address from the jail's configuration under /usr/local/etc/ezjail/<jailname>?  Additionally, any network config shown by `grep ifconfig /etc/rc.conf` would be useful to post.  Thanks.


----------



## andrewm659 (Jul 29, 2015)

So this is what I use to create a new jail:

1.  Set up the IP address you want to use for the jail.  Change the IP address to something else on your network.
`# echo 'ifconfig_em0_alias0="inet 192.168.220.73 netmask 255.255.255.0"' >> /etc/rc.conf`

2.  Bring up the new interface
`ifconfig em0 up`
OR

```
/etc/rc.d/netif onerestart
service network onerestart
```
3.  So let's create a jail:
Change the IP address to something on your network
`ezjail-admin create -r /jails/webjail webjail 10.10.10.10`
If you need to allow the jail to ping in/out bound then run this command
`# sed -i '' -e 's/parameters=""/parameters="allow.raw_sockets=1"/g' /usr/local/etc/ezjail/*`

4.  Use the following command to start a specific jail instance
`# service ezjail start jail1.example.com`

5.  Make sure the jail is running
`jls`

6.  Enter the jail console
`ezjail-admin console jail1.example.com`


----------



## junovitch@ (Jul 30, 2015)

There are two methods of going about this.  You can either assign all the IP addresses as aliases up front in /etc/rc.conf or you can let the jail(8) system assign them on the fly. I'm not entirely sure which you are taking since the examples you have shown have a bit of a disconnect between using the 192.168.220.0/24 on the interface but 10.10.10.10 on the jail.  I'll just explain both methods and if you can clarify for me which you are attempting to use that would be helpful.

rc.conf aliases:

I am assuming you also have a main address on the interface, something like this in your rc.conf:

```
ifconfig_em0="inet 192.168.220.72/24"
ifconfig_em0_alias0="inet 192.168.220.73/24"
```
In this case, you would use `ezjail-admin create -r /jails/webjail webjail 192.168.220.73` with the already existing IP address alias.  Your example with 10.10.10.10 doesn't make this clear which route you are taking.

jail(8) assigned aliases:

In this case it would just be this in your rc.conf

```
ifconfig_em0="inet 192.168.220.72/24"
```
The command you would use would just be `ezjail-admin create -r /jails/webjail webjail 'em0|192.168.220.73'`.


----------



## andrewm659 (Jul 30, 2015)

The 10.10.10.10 was an example.

The IP address of the machine is 192.168.220.70 and I am creating aliases by echoing them into the rc.conf.


----------



## junovitch@ (Jul 31, 2015)

andrewm659 said:


> The 10.10.10.10 was an example.
> 
> The IP address of the machine is 192.168.220.70 and I am creating aliases by echoing them into the rc.conf.



In that case, this should be enough.  You don't need to completely restart networking to add an alias.
`echo 'ifconfig_em0_alias0="inet 192.168.220.73/24"' >> /etc/rc.conf
ifconfig em0 inet 192.168.220.73/24 alias
ezjail-admin create -r /jails/webjail webjail 192.168.220.73`

If you do this, is your jail still having networking issues?


----------



## andrewm659 (Aug 4, 2015)

Ah ok.  I will try this and let you know.  Thank you again!

I have more questions about different stuff.  Going in a diff thread.


----------



## junovitch@ (Aug 4, 2015)

Sounds good.  One thread for one topic is best.  If you have any more issues with this particular network matter then please continue.  If things work out then go ahead and edit your thread to mark it with the SOLVED tag.


----------

