Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a Linux server that gets a time offset for some strange reason. I set up cron job to run and update the time using the following command:

/usr/sbin/ntpdate pool.ntp.org

The problem is the command would not run because I have a firewall (iptables).

I have always used IP to allow traffic in my network:

iptables -A INPUT -p tcp -m tcp -i eth0 -s 11.11.11.11 --dport 5060 -j ACCEPT

I would like to know how to do it using a domain name in this case would be pool.ntp.org, or maybe someone could tell me a better way to keep the clocks in sync.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

To allow a NTP client to talk to a server you can use these rules:

$ sudo iptables -A OUTPUT -p udp --dport 123 -j ACCEPT
$ sudo iptables -A INPUT -p udp --sport 123 -j ACCEPT

To act as a NTP server and accept client connections:

$ sudo iptables -A INPUT -p udp --dport 123 -j ACCEPT
$ sudo iptables -A OUTPUT -p udp --sport 123 -j ACCEPT

References

share|improve this answer
    
Thanks! excatly What i needed –  meda Aug 1 '13 at 19:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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