# NTP can't resolve host names



## dennylin93 (Jan 17, 2010)

I upgraded to RELENG_8_0 a while ago, and I noticed that ntpd couldn't resolve host names during the boot process.

This is what pops up on the console:

```
Jan 16 17:03:12 mail kernel: Jan 16 17:03:12 mail ntpd_initres[1101]: host name not found: 0.tw.pool.ntp.org
Jan 16 17:03:12 mail kernel: Jan 16 17:03:12 mail ntpd_initres[1101]: couldn't resolve `0.tw.pool.ntp.org', giving up on it
Jan 16 17:03:12 mail kernel: Jan 16 17:03:12 mail ntpd_initres[1101]: host name not found: 1.tw.pool.ntp.org
Jan 16 17:03:12 mail kernel: Jan 16 17:03:12 mail ntpd_initres[1101]: couldn't resolve `1.tw.pool.ntp.org', giving up on it
Jan 16 17:03:12 mail kernel: Jan 16 17:03:12 mail ntpd_initres[1101]: host name not found: 2.tw.pool.ntp.org
Jan 16 17:03:12 mail kernel: Jan 16 17:03:12 mail ntpd_initres[1101]: couldn't resolve `2.tw.pool.ntp.org', giving up on it
```

I have to do `# /etc/rc.d/ntpd restart` manually every time I reboot, or else ntpd won't work. The order of the scripts in /etc/rc.d/ seem to be correct, so I'm not sure what's causing the problem.


----------



## crsd (Jan 17, 2010)

Try changing DHCP to SYNCDHCP in ifconfig_<ifaceN> (if you are using DHCP, of course  )


----------



## fronclynne (Jan 17, 2010)

crsd said:
			
		

> Try changing DHCP to SYNCDHCP in ifconfig_<ifaceN> (if you are using DHCP, of course  )



Purely out of curiosity  where is this documented?


----------



## crsd (Jan 17, 2010)

rc.conf(5). Check *synchronous_dhclient* variable also.


----------



## dennylin93 (Jan 17, 2010)

crsd said:
			
		

> Try changing DHCP to SYNCDHCP in ifconfig_<ifaceN> (if you are using DHCP, of course  )



Unfortunately, I'm not using DHCP, so I hope there's another work around I can use.


----------



## graudeejs (Jan 17, 2010)

show /etc/rc.conf


----------



## dennylin93 (Jan 17, 2010)

Here it is (I removed some unrelated parts):

```
defaultrouter="10.0.0.1"
hostname="example.com"
ifconfig_bge0="inet 10.0.0.2 netmask 255.255.255.0"

# PF
pf_enable="YES"
pflog_enable="YES"
pflog_logfile="/var/log/pflog/pflog"

ntpd_enable="YES"
```

This problem appeared after I upgraded to RELENG_8_0 from RELENG_7_2.


----------



## graudeejs (Jan 17, 2010)

ok show pf.conf perhaps you're blocking access to DNS

Also if you want to simply sync clock with internet use ntpdate
here's mine:

```
ntpdate_enable="YES"
ntpdate_hosts="ntp.linux.edu.lv"
```


----------



## BobBilly5 (Jan 17, 2010)

I had the same problem when I ran tinydns/dnscache and only had 127.0.0.1 in /etc/resolv.conf....
What if you specify those ntp hosts by IP instead of name, does it make a difference?


----------



## dennylin93 (Jan 17, 2010)

killasmurf86 said:
			
		

> ok show pf.conf perhaps you're blocking access to DNS
> 
> Also if you want to simply sync clock with internet use ntpdate
> here's mine:
> ...



I think my configuration is ok. I didn't do any major changes when I went from 7.2 to 8.0, and ntpd works if I restart it using `# /etc/rc.d/ntpd`. The problem seems to be with the boot process/scripts.



			
				BobBilly5 said:
			
		

> I had the same problem when I ran tinydns/dnscache and only had 127.0.0.1 in /etc/resolv.conf....
> What if you specify those ntp hosts by IP instead of name, does it make a difference?



It would probably work, but I'd prefer to know why host names don't work properly like they used to. I'll see if I can reproduce this on a fresh install.


----------



## J65nko (Jan 17, 2010)

If you are running a nameserver on that box it needs to be started before ntpd.Have you checked with rcorder(8) whether that happens?

What is the contents of your "/etc/resolv.conf" file?


----------



## jalla (Jan 17, 2010)

> Also if you want to simply sync clock with internet use ntpdate
> here's mine:
> 
> ```
> ...



ntpdate will sync your clock at boot, but won't keep it sync'ed unless you put it in cron.

Also, note that ntpdate is deprecated. ntpd is the way to go for the future


----------



## graudeejs (Jan 17, 2010)

hmm didn't know it was deprecated....
And it's for my desktop so syncing once at boot is just what I want


----------



## jalla (Jan 17, 2010)

killasmurf86 said:
			
		

> hmm didn't know it was deprecated....
> And it's for my desktop so syncing once at boot is just what I want



From ntpdate(8)


> Note: The functionality of this program is now available in the ntpd(8)
> program.  See the -q command line option in the ntpd(8) page.  After a
> suitable period of mourning, the ntpdate utility is to be retired from
> this distribution


.


----------



## joel@ (Jan 17, 2010)

FWIW, I see the same thing on a machine running 8.0.


----------



## dennylin93 (Jan 20, 2010)

On a few computers, the error disappeared after reboot, but the problem still persists on 2 computers. I tried tweaking a few things, but I still haven't found the cause of the problem yet.


----------



## SirDice (Jan 20, 2010)

Make sure /etc/resolv.conf contains the correct IP addresses for your DNS servers.


----------



## dennylin93 (Jan 20, 2010)

SirDice said:
			
		

> Make sure /etc/resolv.conf contains the correct IP addresses for your DNS servers.



They're ok. NTP just doesn't work during the boot process. It works if I restart it manually using `# /etc/rc.d/ntpd`.


----------



## DutchDaemon (Jan 20, 2010)

I only use ntpdate with IP addresses of NTP servers in rc.conf. That takes care of setting the correct time at boot without problems. The 'regular' ntpd server that starts after that (I use openntpd) has NTP server names in its config file, which works fine.


----------



## SirDice (Jan 20, 2010)

Yeah, I use ntpd too, with hostnames. The only 'problem' I have is ntpd can't bind to the workstation's IPv6 address. The IPv6 address (rtadvd/rtsol) seems to get set rather late (I'm talking minutes after the system is fully booted). Every few updates this process seems to get fixed, next update it's broken again, next it's fixed etc.


----------

