Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 --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
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


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

Your Answer


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.