2

I'm using Linux Debian Wheezy.I have problem to sync time & date between my server & PC,and the ntp servers looks like pointing at itself not internet.

In this case,Fig is my NTP server.

root@fig [5156]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 fig.nta-monitor .INIT.          16 u    - 1024    0    0.000    0.000   0.000

My NTP Server ntp.conf file:

root@fig [5155]# less /etc/ntp.conf
# /etc/ntp.conf, configuration for ntpd

driftfile /var/lib/ntp/ntp.drift
statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

server 0.my.pool.ntp.org iburst
server 1.my.pool.ntp.org iburst
server 2.my.pool.ntp.org iburst
server 3.my.pool.ntp.org iburst
server 0.asia.pool.ntp.org iburst
server 1.asia.pool.ntp.org iburst

# ... and use the local system clock as a reference if all else fails
# NOTE: in a local network, set the local stratum of *one* stable server
# to 10; otherwise your clocks will drift apart if you lose connectivity.
server 127.127.1.0
fudge 127.127.1.0 stratum 13

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1 nomodify

This is the information for my server & client

NTP Server = 192.168.120.104 (Fig) 
Client = 192.168.120.65 (Banana) 

Please advice.Thanks

Now the issue is why my NTP server used itself as ntp server?


This is what I ping for the pool from NTP server(fig)

root@fig [5246]# ping 0.my.pool.ntp.org
PING 0.my.pool.ntp.org (202.45.138.123) 56(84) bytes of data.


But got reply when i ping to yahoo.com

root@fig [5247]# ping yahoo.com
PING yahoo.com (98.138.253.109) 56(84) bytes of data.
64 bytes from ir1.fp.vip.ne1.yahoo.com (98.138.253.109): icmp_req=1 ttl=39 time=333 ms
64 bytes from ir1.fp.vip.ne1.yahoo.com (98.138.253.109): icmp_req=2 ttl=39 time=332 ms
64 bytes from ir1.fp.vip.ne1.yahoo.com (98.138.253.109): icmp_req=3 ttl=39 time=332 ms
64 bytes from ir1.fp.vip.ne1.yahoo.com (98.138.253.109): icmp_req=4 ttl=39 time=335 ms
^C
--- yahoo.com ping statistics ---
5 packets transmitted, 4 received, 20% packet loss, time 4003ms
rtt min/avg/max/mdev = 332.398/333.454/335.464/1.263 ms

This is the output when I run ps -ef | grep [n]tp command

root@fig [5213]# ps -ef | grep [n]tp
ntp      22526     1  0 13:24 ?        00:00:01 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -c /var/lib/ntp/ntp.conf.dhcp -u 101:108


This is the result when I run ntpdate -qu 202.45.138.123 command

root@fig [5215]# ntpdate -qu 202.45.138.123
server 202.45.138.123, stratum 2, offset -135.572409, delay 0.06105
 1 Sep 19:18:29 ntpdate[27420]: step time server 202.45.138.123 offset -135.572409 sec
Kamal
  • 53
  • @Rahul Did you mean manually? – Kamal Sep 01 '16 at 09:21
  • I mean if you turned off ntpd can you update the clock by command line? – Rahul Sep 01 '16 at 09:23
  • @Rahul I think my ntp server need to follow Malaysia — my.pool.ntp.org server,but somehow it point to itself.I already change it manually,but it not sync with client – Kamal Sep 01 '16 at 09:28
  • You should have one entry in the list from ntpq -p for each of your server lines. Since you've only got the fudged localhost entry I would say that ntpd couldn't resolve the server names when it started. If you restart the daemon does it start working as expected? – Chris Davies Sep 01 '16 at 09:28
  • Hi,this is the ntpq -p for my client.Looks like it point to my ntp server.
     
    
    root@banana [531]# ntpq -p
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
     fig.nta-monitor .INIT.          16 u   55  512    0    0.000    0.000   0.000
    root@banana [532]#
    
    – Kamal Sep 01 '16 at 09:37
  • There's no point looking at your client until your server is sorted. The output from ntpq -p in your question is from fig, yes? – Chris Davies Sep 01 '16 at 09:47
  • How to add the format inside here?

    This is the output for fig ntpq -p

    root@fig [5230]# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== fig.nta-monitor .INIT. 16 u - 1024 0 0.000 0.000 0.000

    – Kamal Sep 01 '16 at 09:49
  • @roaima i only restart using this command /etc/init.d/ntp restart at ntp server,looks like it still point to itself. – Kamal Sep 01 '16 at 10:44
  • On fig can you resolve the name 0.my.pool.ntp.org successfully? (Use ping or something. It doesn't matter whether the host replies. What's important is that the name resolves to an IP address.) – Chris Davies Sep 01 '16 at 10:48
  • Thank you. This is good because it shows that 0.my.pool.ntp.org currently resolves to 202.45.138.123. For me, that is a valid NTP server. So, please can you provide output of running this command on fig - ps -ef | grep [n]tp. Also the output of ntpdate -qu 202.45.138.123 (you may need to install the ntpdate package). – Chris Davies Sep 01 '16 at 11:10

2 Answers2

3

Your ntpd is not using your expected configuration file /etc/ntp.conf.

Looking at the output of ps -ef | grep [n]tp you can see that the configuration file is /var/lib/ntp/ntp.conf.dhcp, which will probably contain data from DHCP.

There are a couple of great answers over on Server Fault that explain how to fix this. The summary is that you need to tell fig not to configure NTP from DHCP.

Edit /etc/dhclient.conf and uncomment the line "request" with something like this:

request subnet-mask, broadcast-address, routers, domain-name, domain-name-servers, host-name;

Especially, if ntp-servers is present, remove it. Under some distribution ( aka Fedora ) it is sent by default, so you have to put this line explicitly so that the default is overridden.

You may also need to remove /var/lib/ntp/ntp.conf.dhcp once you've got a new DHCP lease.

Chris Davies
  • 116,213
  • 16
  • 160
  • 287
0

When using "NTP server pools" (what you obviously do), use the pool keyword instead of server.

U. Windl
  • 1,411