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
  • @Rahul Did you mean manually? – Kamal Sep 1 '16 at 9:21
  • I mean if you turned off ntpd can you update the clock by command line? – Rahul Sep 1 '16 at 9: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 1 '16 at 9: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? – roaima Sep 1 '16 at 9:28
  • Hi,this is the ntpq -p for my client.Looks like it point to my ntp server. <pre> 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]# </pre> – Kamal Sep 1 '16 at 9:37
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.

  • This is my /etc/dhclient.conf file, request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, host-name, ntp-servers; Did i need to remove ntp-servers from that file? – Kamal Sep 1 '16 at 11:42
  • « Especially, if ntp-servers is present, remove it » – roaima Sep 1 '16 at 11:46
  • is it related with dhcp?Because currently my server(fig) are using static ip. – Kamal Sep 1 '16 at 12:16
  • « You may also need to remove /var/lib/ntp/ntp.conf.dhcp » – roaima Sep 1 '16 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.