Results 1 to 8 of 8

Thread: Iptables: how to open network time servers

  1. #1
    Join Date
    Sep 2007
    Beans
    297

    Iptables: how to open network time servers

    Hi everyone,

    I placed this command to protect my computers:

    /sbin/iptables -A OUTPUT -j REJECT

    I realized though that this closes the computers from receiving time from it's network time servers. How do I keep the computer's access to network time servers open?

  2. #2
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    3,515
    Distro
    Ubuntu Development Release

    Re: Iptables: how to open network time servers

    Actually, the rule prevents your computer from even asking for NTP stuff in the first place. You have to allow your computer access to external port 123, or if you know the IP address of the NTP server you could allow that IP address. Something like:
    Code:
    /sbin/iptables -A OUTPUT --dport 123 -j ACCEPT
    /sbin/iptables -A OUTPUT -j REJECT
    You might find you need to also allow traffic to/from the local interface:
    Code:
    /sbin/iptables -A OUTPUT -o lo -j ACCEPT
    /sbin/iptables -A OUTPUT --dport 123 -j ACCEPT
    /sbin/iptables -A OUTPUT -j REJECT
    Without the bigger context of what you are trying to do, it is hard to comment further.
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

  3. #3
    Join Date
    Sep 2007
    Beans
    297

    Re: Iptables: how to open network time servers

    Is this the line that opens the local interface?

    /sbin/iptables -A OUTPUT -o lo -j ACCEPT

    Io is a small "L" right, it's not a big "i"?

  4. #4
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    3,515
    Distro
    Ubuntu Development Release

    Re: Iptables: how to open network time servers

    Quote Originally Posted by webmiester View Post
    Is this the line that opens the local interface?

    /sbin/iptables -A OUTPUT -o lo -j ACCEPT

    Io is a small "L" right, it's not a big "i"?
    Yes and yes.
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

  5. #5
    Join Date
    Sep 2007
    Beans
    297

    Re: Iptables: how to open network time servers

    Quote Originally Posted by Doug S View Post
    Code:
    /sbin/iptables -A OUTPUT -o lo -j ACCEPT
    /sbin/iptables -A OUTPUT --dport 123 -j ACCEPT
    /sbin/iptables -A OUTPUT -j REJECT
    Without the bigger context of what you are trying to do, it is hard to comment further.
    How about:

    /sbin/iptables -A OUTPUT -d 127.0.0.1 -j ACCEPT

    Will this do the same thing?

  6. #6
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    7,700

    Re: Iptables: how to open network time servers

    Quote Originally Posted by webmiester View Post
    How about:

    /sbin/iptables -A OUTPUT -d 127.0.0.1 -j ACCEPT

    Will this do the same thing?
    No. That only allows the host to talk to itself on its own loopback port.

    I don't recommend blocking OUTPUT. It will break lots of things.

    Oh, and when specifying a port number, you have to specify tcp or udp as well. Like this:
    Code:
    /sbin/iptables -A OUTPUT -p tcp  --dport 123 -j ACCEPT

  7. #7
    Join Date
    Sep 2007
    Beans
    297

    Re: Iptables: how to open network time servers

    Quote Originally Posted by The Cog View Post
    No. That only allows the host to talk to itself on its own loopback port.

    I don't recommend blocking OUTPUT. It will break lots of things.

    Oh, and when specifying a port number, you have to specify tcp or udp as well. Like this:
    Code:
    /sbin/iptables -A OUTPUT -p tcp  --dport 123 -j ACCEPT
    Oh thanks.

  8. #8
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    3,515
    Distro
    Ubuntu Development Release

    Re: Iptables: how to open network time servers

    Quote Originally Posted by The Cog View Post
    Oh, and when specifying a port number, you have to specify tcp or udp as well. Like this:
    Code:
    /sbin/iptables -A OUTPUT -p tcp  --dport 123 -j ACCEPT
    My syntax mistake, sorry.
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •