# ntpdate[4850]: can't find host 0

## samo

Hi,

I get the following error during startup:

```
# grep ntp /var/log/messages

Jan 31 10:32:40 gentoo ntpdate[4850]: can't find host 0.gentoo.pool.ntp.org

Jan 31 10:32:40 gentoo ntpdate[4850]: can't find host 1.gentoo.pool.ntp.org

Jan 31 10:32:40 gentoo ntpdate[4850]: can't find host 2.gentoo.pool.ntp.org

Jan 31 10:32:40 gentoo ntpdate[4850]: can't find host 3.gentoo.pool.ntp.org

Jan 31 10:32:40 gentoo ntpdate[4850]: no servers can be used, exiting
```

My init-scripts are configured as follows:

```
# rc-update show

           alsasound | boot

             apache2 |      default

            bootmisc | boot

             checkfs | boot

           checkroot | boot

               clock | boot

         consolefont | boot

               cupsd |      default

                dbus |      default

          fbcondecor | boot

                hald |      default

            hostname | boot

             keymaps | boot

               local |      default nonetwork

          localmount | boot

             modules | boot

               mysql |      default

         mythbackend |      default

              net.lo | boot

            netmount |      default

          ntp-client |      default

           rmnologin | boot

              serial | boot

           syslog-ng |      default

             urandom | boot

          vixie-cron |      default

                wicd | boot

                 xdm |      default

              xinetd |      default
```

And /etc/init.d/ntp-client is adjusted in the following way:

```
depend() {

        before cron portmap

#       need net

        after net.wlan0 || after net.eth0

        use dns logger

}
```

After login I can successfully start ntp-client. It seems like ntp-client is running in timeout during boot.

----------

## Ato

It seems that you have no network interface up but lo when ntp starts.  Perhaps you want to add something like net.eth0 or net.wlan0 to the boot or default levels.

Cheers,

    T.

----------

## PaulBredbury

There's a crazy contradiction with ntp starting before logging. Logging wants to know the right time, but networking (and BIND, if you're using BIND to name-resolve) needs to be up to be able to name-resolve and contact the timeservers  :Razz: 

At one point, I resolved this startup order paradox between ntp and bind, by having in /etc/ntp.conf

```
# From http://www.pool.ntp.org/zone/th

server 2.th.pool.ntp.org prefer

server 3.asia.pool.ntp.org

server 2.asia.pool.ntp.org
```

Notice that "prefer". And in /etc/hosts

```
# For ntp at startup, because it starts before bind/named

158.108.2.100   2.th.pool.ntp.org
```

Not perfect, but it works.

----------

## samo

My settings look like this:

```
# cat /etc/ntp.conf

# Generated by dhclient for interface eth0

restrict default noquery notrust nomodify

restrict 127.0.0.1

restrict 192.168.178.1 nomodify notrap noquery

server 192.168.178.1

driftfile /var/lib/ntp/ntp.drift

logfile /var/log/ntp.log
```

```
# cat /etc/hosts

127.0.0.1 gentoo.home gentoo localhost

::1 localhost
```

How can I check, if I use BIND?

I wonder about /etc/ntp.conf, because I don't use dhclient but static IP's

----------

## samo

I've changed ntp.conf like this:

```
# cat /etc/ntp.conf                      

# NOTES:                                               

# DHCP clients can append or replace NTP configuration files.

# You should consult your DHCP client documentation about its

# default behaviour and how to change it.                    

# Name of the servers ntpd should sync with

# Please respect the access policy as stated by the responsible person.

#server         ntp.example.tld         iburst                         

# Common pool for random people

#server pool.ntp.org           

# Pools for Gentoo users

server 0.gentoo.pool.ntp.org

server 1.gentoo.pool.ntp.org

server 2.gentoo.pool.ntp.org

server 3.gentoo.pool.ntp.org

##

# A list of available servers can be found here:

# http://www.pool.ntp.org/

# http://www.pool.ntp.org/#use

# A good way to get servers for your machine is:

# netselect -s 3 pool.ntp.org

##

# you should not need to modify the following paths

driftfile       /var/lib/ntp/ntp.drift

#server ntplocal.example.com prefer

#server timeserver.example.org

# Warning: Using default NTP settings will leave your NTP

# server accessible to all hosts on the Internet.

# If you want to deny all machines (including your own)

# from accessing the NTP server, uncomment:

#restrict default ignore

# To deny other machines from changing the

# configuration but allow localhost:

restrict default nomodify nopeer

restrict 127.0.0.1

# To allow machines within your network to synchronize

# their clocks with your server, but ensure they are

# not allowed to configure the server or used as peers

# to synchronize against, uncomment this line.

#

#restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap
```

But I get the some errors.

----------

## samo

I've changed my settings as follows:

```
# cat /etc/hosts

127.0.0.1 gentoo.home gentoo localhost

::1 localhost

64.73.32.135 0.gentoo.pool.ntp.org

67.22.149.171 1.gentoo.pool.ntp.org

72.18.205.156 2.gentoo.pool.ntp.org

169.229.70.95 3.gentoo.pool.ntp.org
```

```
# cat /etc/ntp.conf                                             

# NOTES:                                                                      

# DHCP clients can append or replace NTP configuration files.                 

# You should consult your DHCP client documentation about its                 

# default behaviour and how to change it.                                     

# Name of the servers ntpd should sync with

# Please respect the access policy as stated by the responsible person.

#server         ntp.example.tld         iburst                         

# Common pool for random people

#server pool.ntp.org           

# Pools for Gentoo users

server 0.gentoo.pool.ntp.org prefer

server 1.gentoo.pool.ntp.org       

server 2.gentoo.pool.ntp.org       

server 3.gentoo.pool.ntp.org       

##

# A list of available servers can be found here:

# http://www.pool.ntp.org/

# http://www.pool.ntp.org/#use

# A good way to get servers for your machine is:

# netselect -s 3 pool.ntp.org

##

# you should not need to modify the following paths

driftfile       /var/lib/ntp/ntp.drift

#server ntplocal.example.com prefer

#server timeserver.example.org

# Warning: Using default NTP settings will leave your NTP

# server accessible to all hosts on the Internet.

# If you want to deny all machines (including your own)

# from accessing the NTP server, uncomment:

#restrict default ignore

# To deny other machines from changing the

# configuration but allow localhost:

restrict default nomodify nopeer

restrict 127.0.0.1

# To allow machines within your network to synchronize

# their clocks with your server, but ensure they are

# not allowed to configure the server or used as peers

# to synchronize against, uncomment this line.

#

#restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap
```

But I'm still getting the following error:

```
# grep ntp /var/log/messages 

Feb  6 12:17:11 gentoo ntpdate[4943]: no servers can be used, exiting
```

----------

## samo

Problem is still pending. Could someone help?

----------

## PaulBredbury

Look at Ato's answer. Ntp needs access to the Internet, of course - you've not shown that you're providing that.

----------

## cwr

Try and ping one of the ntp servers.  If ping works, its probably a problem

with ntp - possibly your machine's time is too far from the standard for

ntp to want to reset it.  If ping doesn't work, then use ifconfig to see how

your networking is configured and post the results.

Will

----------

## samo

ping works correctly.

```
# ping -c 5 0.gentoo.pool.ntp.org

PING 0.gentoo.pool.ntp.org (64.73.32.135) 56(84) bytes of data.

64 bytes from 0.gentoo.pool.ntp.org (64.73.32.135): icmp_seq=1 ttl=51 time=171 ms

64 bytes from 0.gentoo.pool.ntp.org (64.73.32.135): icmp_seq=2 ttl=51 time=171 ms

64 bytes from 0.gentoo.pool.ntp.org (64.73.32.135): icmp_seq=3 ttl=51 time=171 ms

64 bytes from 0.gentoo.pool.ntp.org (64.73.32.135): icmp_seq=4 ttl=51 time=170 ms

64 bytes from 0.gentoo.pool.ntp.org (64.73.32.135): icmp_seq=5 ttl=51 time=173 ms

--- 0.gentoo.pool.ntp.org ping statistics ---

5 packets transmitted, 5 received, 0% packet loss, time 4015ms

rtt min/avg/max/mdev = 170.769/171.770/173.774/1.178 ms
```

And also ntpd works correctly when I start it manually at command promt.

```
# /etc/init.d/ntpd start

 * Starting ntpd ...                                                                                                   [ ok ]
```

Maybe the connection is established to late. Could I modify the timeout setting of ntp?

----------

## samo

Please read  this topic

----------

