# ntp-client: "Error : Servname not supported for ai_socktype"

## jsporring

Hi,

ntp-client suddenly stopped working on my laptop, I guess after an stable upgrade, but I really don't know.  I first notice it at boot time, but I can repeat the problem by:

```

rose etc # /etc/init.d/ntpd restart

 * Caching service dependencies ...                                            [ ok ]

 * Stopping ntpd ...                                                           [ ok ]

 * Starting ntpd ...                                                           [ ok ]

rose etc # /etc/init.d/ntp-client restart

 * Setting clock via the NTP client 'ntpdate' ...

Error : Servname not supported for ai_socktype

 6 Sep 14:18:45 ntpdate[25510]: can't find host 88.198.46.111

Error : Servname not supported for ai_socktype

 6 Sep 14:18:45 ntpdate[25510]: can't find host 195.85.225.211

Error : Servname not supported for ai_socktype

 6 Sep 14:18:45 ntpdate[25510]: can't find host 62.112.154.21

 6 Sep 14:18:45 ntpdate[25510]: no servers can be used, exiting

 * Failed to set clock                                                         [ !! ]

```

I originally thought that it was a problem with the hosts, so the above hosts are new ones I found using 

```

rose log # netselect -s 3 pool.ntp.org

   91 88.198.46.111

   94 195.85.225.211

  108 62.112.154.21

```

I also tried reverting to the original ntp.conf file with 

```

server 0.dk.pool.ntp.org

server 1.europe.pool.ntp.org

server 2.europe.pool.ntp.org

```

added according to http://www.pool.ntp.org/ .  But this has had no effect.  Without knowing what else to look for I've checked several things:

version (I have done a emerge -1 to be sure):

```

rose etc # equery list ntp

[ Searching for package 'ntp' in all categories among: ]

 * installed packages

[I--] [  ] net-misc/ntp-4.2.4_p0 (0)

```

/etc/services:

```

[...]

nntp            119/tcp         readnews untp   # Network News Transfer Protocol

nntp            119/udp         readnews untp

[...]

ntp             123/tcp                         # Network Time Protocol

ntp             123/udp

[...]

```

/etc/conf.d/net

```

[...]

dhcpcd_eth0="-Y -N -t 15"

[...]

```

My /etc/ntp.conf looks like:

```

# NOTES:

#  - you should only have to update the server line below

#  - if you start getting lines like 'restrict' and 'fudge'

#    and you didnt add them, AND you run dhcpcd on your

#    network interfaces, be sure to add '-Y -N' to the

#    dhcpcd_ethX variables in /etc/conf.d/net

# Name of the servers ntpd should sync with

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

#server      ntp.example.tld      iburst

server 0.dk.pool.ntp.org

server 1.europe.pool.ntp.org

server 2.europe.pool.ntp.org

server 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

and my /etc/conf.d/ntp-client looks like:

# /etc/conf.d/ntp-client

# Command to run to set the clock initially

# Most people should just leave this line alone ...

# however, if you know what you're doing, and you

# want to use ntpd to set the clock, change this to 'ntpd'

NTPCLIENT_CMD="ntpdate"

# Options to pass to the above command

# This default setting should work fine but you should

# change the default 'pool.ntp.org' to something closer

# to your machine.  See http://www.pool.ntp.org/ or

# try running `netselect -s 3 pool.ntp.org`.

#NTPCLIENT_OPTS="-s -b -u pool.ntp.org"

#NTPCLIENT_OPTS="-b -u 130.225.96.8 130.225.96.9 130.225.96.10" # 15/6/05, Jon Sporring

NTPCLIENT_OPTS="-b 88.198.46.111 195.85.225.211 62.112.154.21" # 15/6/05, Jon Sporring

NTPCLIENT_TIMEOUT=10 # 15/6/05, Jon Sporring

```

Any help would be much appreciated.

Thanks, Jon

----------

## embobo

Try this:

```

getent services | grep ntp

...

ntp                   123/tcp

ntp                   123/udp

```

If you don't see that have a look at /etc/nsswitch.conf.

Goog luck!   :Smile: 

----------

## embobo

 *Quote:*   

> 0.dk.pool.ntp.org

 

One more thing: those names violate rfc952:

 *Quote:*   

> 
> 
> The first character must be an alpha character.
> 
> 

 

http://tools.ietf.org/html/rfc952

----------

## jsporring

Good tip, the file /etc/services, for some reason had been renamed to /etc/service.  I'm not sure why, so I made a link, and now everything is working again.  Thanks. 

```

rose etc # /etc/init.d/ntp-client restart

 * Setting clock via the NTP client 'ntpdate' ...

Error : Servname not supported for ai_socktype

10 Sep 16:58:37 ntpdate[7410]: can't find host 88.198.46.111

Error : Servname not supported for ai_socktype

10 Sep 16:58:37 ntpdate[7410]: can't find host 195.85.225.211

Error : Servname not supported for ai_socktype

10 Sep 16:58:37 ntpdate[7410]: can't find host 62.112.154.21

10 Sep 16:58:37 ntpdate[7410]: no servers can be used, exiting

 * Failed to set clock                                                         [ !! ]

rose etc # getent services

rose etc # ls -l service*

-rw-r--r-- 1 root root 35858 2006-02-13 11:04 service

-rw-r--r-- 1 root root     0 2007-08-22 15:00 services

rose etc # mv services ~

rose etc # ln -s service services

rose etc # /etc/init.d/ntp-client restart

 * Setting clock via the NTP client 'ntpdate' ...

10 Sep 17:06:08 ntpdate[7700]: step time server 88.198.46.111 offset -16.1292  [ ok ]

```

----------

## embobo

 *embobo wrote:*   

>  *Quote:*   0.dk.pool.ntp.org 
> 
> One more thing: those names violate rfc952:
> 
>  *Quote:*   
> ...

 

I sent mail to the ntp pool list. My info was outdated:

 *Quote:*   

> 
> 
> The hostname specification has been updated since the RFC you mention above
> 
> (cf http://www.ietf.org/rfc/rfc1123.txt):
> ...

 

----------

