# Slow start of jail (ezjail)



## blazingice (May 2, 2013)

I have created a jail using sysutils/ezjail.

`#ezjail-admin create jailname 'em0|192.168.1.22'`

In order to get internet connection from the jail I copied the host resolv.conf to the jail. After I did that, it takes a very long time to start the jail. If I remove resolv.conf from the jail, then there is no delay. The host's resolv.conf looks like this:

```
# Generated by resolvconf
nameserver 194.168.4.100
nameserver 194.168.8.100
```
Also if I change the resolv.conf of the jail to use a Google server, then I have no problems

```
#Google Public DNS
nameserver 8.8.8.8
nameserver 8.8.4.4
```
I am happy to use a Google server, but am not sure if it is advisable. Is there any reason why my jail takes so long to start when using host's resolv.conf?


----------



## Ben (May 2, 2013)

After the jail started you can resolve domain names easily/fast?

You had a look at the logfiles of your DNS?


----------



## SirDice (May 2, 2013)

Make sure the jail can resolve itself (hostname and IP address) either with a hosts file or DNS. That's usually the biggest delay.


----------



## blazingice (May 2, 2013)

Thanks for the suggestions. I entered the hostname of the jail in the etc/hosts of the jail. This solved the problem. The jail starts without any delays while still using host's etc/resolv.conf

However, I don't understand why Google's DNS server would not face the same problem as the host details.


----------



## SirDice (May 3, 2013)

DNS isn't something dynamic, although it can be it's not on the Internet. So hostnames need to be registered. If the hostname isn't registered there's no way for any Internet DNS server to resolve the hostname to its IP address. 

When starting the system Sendmail tries to figure out who it is by using DNS and looking at the hostname of the system. If that fails it will cause a delay.


----------



## blazingice (May 3, 2013)

SirDice said:
			
		

> When starting the system Sendmail tries to figure out who it is by using DNS and looking at the hostname of the system. If that fails it will cause a delay.


Thanks. I now understand why there was a delay. 


			
				SirDice said:
			
		

> So hostnames need to be registered. If the hostname isn't registered there's no way for any internet DNS server to resolve the hostname to it's IP address.


But I am struggling to understand why it would work without any delays when using Google public DNS in etc/resolv.conf although the hostname was not added in etc/hosts. So how was the hostname registered to its IP in this case? Is the hostname registered to Google's IP?

It's not a big deal, as it is all sorted now. I just want to learn a bit more.


----------



## SirDice (May 3, 2013)

It now works because it's able to resolve the hostname through /etc/hosts. Name resolving follows the order set in nsswitch.conf(5) and the default order for hosts is files (refers to /etc/hosts), then DNS.

Maybe Google has a few default names set for various IP addresses. As long as the hostname corresponds to that the resolving would appear to magically work.


----------



## ta0kira (May 4, 2013)

SirDice said:
			
		

> Maybe Google has a few default names set for various IP addresses. As long as the hostname corresponds to that the resolving would appear to magically work.


My guess was that the firewall treats the Google address and the 192.168. addresses differently, causing the former to fail immediately and the latter to time out.

Kevin Barry


----------



## blazingice (May 4, 2013)

I had no firewall in my machine. Only if my ADSL/router which does DNS and firewall did what you say.


----------



## ta0kira (May 5, 2013)

blazingice said:
			
		

> I had no firewall in my machine. Only if my ADSL/router which does DNS and firewall did what you say.


Are 194.168.4.100 and 194.168.8.100 on different machines than the jail? To access the network you at least need NAT set up for the jail (I don't use ezjail, so I don't know if it automatically sets that up.) The rules used for NAT (or lack of rules) could cause the different behavior.

Kevin Barry


----------

