0

I have to configure NTP on a CentOS server. I have 7 interfaces and I can reach the NTP server through one interface. Also the server doesn't have access to internet. When I try ping:

ping 10.0.10.12
connect: Network is unreachable

But when I ping with source interface, the ping is successful.

ping -I eth0 10.0.10.12
PING 10.0.0.131 (10.0.10.12) from 10.69.4.16 eth0: 56(84) bytes of data.
64 bytes from 10.0.10.12: icmp_seq=1 ttl=127 time=4.07 ms
64 bytes from 10.0.10.12: icmp_seq=2 ttl=127 time=0.309 ms
64 bytes from 10.0.10.12: icmp_seq=3 ttl=127 time=0.318 ms

ntpstat command output:

unsynchronised
 time server re-starting
  polling server every 8s

ntpq -p command output:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 10.0.10.12      .INIT.          16 -    -  512    0    0.000    0.000   0.000

I also tried ntpdate - d 10.0.10.12:

ntpdate -d 10.0.0.131
23 Jul 09:14:31 ntpdate[16715]: ntpdate 4.2.6p5@1.2349-o Sat Nov 23 18:21:48 UTC 2013 (1)
Looking for host 10.0.0.131 and service ntp
host found : 10.0.0.131
23 Jul 09:14:31 ntpdate[16715]: no servers can be used, exiting

The NTP server is configured in the ntp.conf file, I think that the problem is something with the network. I was wondering if I can make explicit source interface for reaching the NTP server?

ananetworking
  • 33
  • 1
  • 6

2 Answers2

3

You can add a specific host route for your NTP server:

route add -host 10.0.10.12 dev eth0, for example.

As per Anton's completely correct comment, here is the command in iproute2 syntax:

ip route add 10.0.10.12 dev eth0

Lenniey
  • 5,090
  • 2
  • 17
  • 28
-1

I resolved this concluding that NTP requires default gateway for working properly. This was solution for me:

ip route add default via 127.0.0.1 dev lo
ananetworking
  • 33
  • 1
  • 6