× NETGEAR will be terminating ReadyCLOUD service by July 1st, 2023. For more details click here.
Orbi WiFi 7 RBE973
Reply

Re: [SOLVED] NTP-Server & Firewall port settings:

handy1
Aspirant

[SOLVED] NTP-Server & Firewall port settings:

I need a little help with this one please?

I've been using the NTP-Server add-on on my Duo v.1. for many months now. It serves my Linux boxes beautifully.

Anyway, the problem(?):

I just modified the IPTables firewall on a Linux box using gufw, a GUI front end for ufw, which is to the best of my understanding a simplified command line front end for IPTables. After rebooting, everything works very fine, see below (the following was taken immediately after the machine booted):

[handy@jarmano ~]$ time
Local time: Tue 2013-03-05 16:28:04 EST
Universal time: Tue 2013-03-05 05:28:04 UTC
RTC time: Tue 2013-03-05 05:28:04
Timezone: Australia/Sydney (EST, +1100)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
Sun 2012-10-07 01:59:59 EST
Sun 2012-10-07 03:00:00 EST
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2013-04-07 02:59:59 EST
Sun 2013-04-07 02:00:00 EST
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.1.15 .XFAC. 16 u - 128 0 0.000 0.000 0.000
[handy@jarmano ~]$

But the time server stalls my machine for a 90 seconds, before moving on when booting?

Do I have to enable port 123? Do I need to do more than enabling port 123 in the firewall?

Thank you for your time, & please excuse me for invading it?
Message 1 of 12
StephenB
Guru

Re: NTP-Server & Firewall port settings:

What happens when you enter "ntpq -p"?
Message 2 of 12
handy1
Aspirant

Re: NTP-Server & Firewall port settings:

Hi StephenB, thanks for your reply.

Here is the output, from the machine that has probably been running for ~45 mins:

[handy@jarmano ~]$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.1.15 .XFAC. 16 u - 1024 0 0.000 0.000 0.000
Message 3 of 12
handy1
Aspirant

Re: NTP-Server & Firewall port settings:

Following is the output from 3 different commands - lsof -i , netstat -lptu , netstat -tulpn

[handy@jarmano ~]$ sudo lsof -i
[sudo] password for handy:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
cupsd 449 root 10u IPv6 8730 0t0 TCP localhost.localdomain:ipp (LISTEN)
cupsd 449 root 11u IPv4 8731 0t0 TCP localhost.localdomain:ipp (LISTEN)
ntpd 472 ntp 16u IPv4 13452 0t0 UDP *:ntp
ntpd 472 ntp 17u IPv6 13453 0t0 UDP *:ntp
ntpd 472 ntp 18u IPv4 13458 0t0 UDP localhost.localdomain:ntp
ntpd 472 ntp 19u IPv6 13459 0t0 UDP localhost.localdomain:ntp
ntpd 472 ntp 21u IPv6 11851 0t0 UDP jarmano:ntp
ntpd 472 ntp 22u IPv4 11873 0t0 UDP jarmano:ntp
rpcbind 495 root 6u IPv4 13408 0t0 UDP *:sunrpc
rpcbind 495 root 7u IPv4 13463 0t0 UDP *:dhcp-failover
rpcbind 495 root 8u IPv4 13464 0t0 TCP *:sunrpc (LISTEN)
rpcbind 495 root 9u IPv6 13465 0t0 UDP *:sunrpc
rpcbind 495 root 10u IPv6 13466 0t0 UDP *:dhcp-failover
rpcbind 495 root 11u IPv6 13467 0t0 TCP *:sunrpc (LISTEN)
dhclient 503 root 6u IPv4 8925 0t0 UDP *:bootpc
dhclient 503 root 20u IPv4 8918 0t0 UDP *:25021
dhclient 503 root 21u IPv6 8919 0t0 UDP *:bcs-broker
firefox 627 handy 50u IPv4 14324 0t0 TCP jarmano:43047->www.cyberciti.biz:https (SYN_SENT)
firefox 627 handy 64u IPv4 14323 0t0 TCP jarmano:59283->www.cyberciti.biz:http (ESTABLISHED)
firefox 627 handy 66u IPv4 14328 0t0 TCP jarmano:39451->files.cyberciti.biz:http (ESTABLISHED)
firefox 627 handy 67u IPv4 15411 0t0 TCP jarmano:43049->www.cyberciti.biz:https (SYN_SENT)
firefox 627 handy 84u IPv4 12913 0t0 TCP jarmano:58178->secure.imdb.com:https (ESTABLISHED)
firefox 627 handy 109u IPv4 12891 0t0 TCP jarmano:41624->forum.manjaro.org:http (ESTABLISHED)

[handy@jarmano ~]$ sudo netstat -lptu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 *:sunrpc *:* LISTEN 495/rpcbind
tcp 0 0 localhost.localdoma:ipp *:* LISTEN 449/cupsd
tcp6 0 0 [::]:sunrpc [::]:* LISTEN 495/rpcbind
tcp6 0 0 localhost.localdoma:ipp [::]:* LISTEN 449/cupsd
udp 0 0 *:bootpc *:* 503/dhclient
udp 0 0 *:sunrpc *:* 495/rpcbind
udp 0 0 jarmano:ntp *:* 472/ntpd
udp 0 0 localhost.localdoma:ntp *:* 472/ntpd
udp 0 0 *:ntp *:* 472/ntpd
udp 0 0 *:25021 *:* 503/dhclient
udp 0 0 *:dhcp-failover *:* 495/rpcbind
udp6 0 0 [::]:sunrpc [::]:* 495/rpcbind
udp6 0 0 jarmano:ntp [::]:* 472/ntpd
udp6 0 0 localhost.localdoma:ntp [::]:* 472/ntpd
udp6 0 0 [::]:ntp [::]:* 472/ntpd
udp6 0 0 [::]:dhcp-failover [::]:* 495/rpcbind
udp6 0 0 [::]:bcs-broker [::]:* 503/dhclient

[handy@jarmano ~]$ sudo netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 495/rpcbind
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 449/cupsd
tcp6 0 0 :::111 :::* LISTEN 495/rpcbind
tcp6 0 0 ::1:631 :::* LISTEN 449/cupsd
udp 0 0 0.0.0.0:68 0.0.0.0:* 503/dhclient
udp 0 0 0.0.0.0:111 0.0.0.0:* 495/rpcbind
udp 0 0 192.168.1.4:123 0.0.0.0:* 472/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 472/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 472/ntpd
udp 0 0 0.0.0.0:25021 0.0.0.0:* 503/dhclient
udp 0 0 0.0.0.0:647 0.0.0.0:* 495/rpcbind
udp6 0 0 :::111 :::* 495/rpcbind
udp6 0 0 fe80::fad1:11ff:fe0:123 :::* 472/ntpd
udp6 0 0 ::1:123 :::* 472/ntpd
udp6 0 0 :::123 :::* 472/ntpd
udp6 0 0 :::647 :::* 495/rpcbind
udp6 0 0 :::1704 :::* 503/dhclient
[handy@jarmano ~]$
Message 4 of 12
handy1
Aspirant

Re: NTP-Server & Firewall port settings:

Following is without the firewall running:

 [handy@jarmano ~]$ sudo netstat -tulpn
[sudo] password for handy:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 398/rpcbind
tcp 0 0 0.0.0.0:37872 0.0.0.0:* LISTEN 421/rpc.statd
tcp 0 0 0.0.0.0:58359 0.0.0.0:* LISTEN 422/rpc.statd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 360/cupsd
tcp 0 0 0.0.0.0:58904 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:52026 0.0.0.0:* LISTEN 425/rpc.statd
tcp6 0 0 :::41386 :::* LISTEN 425/rpc.statd
tcp6 0 0 :::111 :::* LISTEN 398/rpcbind
tcp6 0 0 :::52627 :::* LISTEN -
tcp6 0 0 :::33524 :::* LISTEN 421/rpc.statd
tcp6 0 0 ::1:631 :::* LISTEN 360/cupsd
tcp6 0 0 :::45277 :::* LISTEN 422/rpc.statd
udp 0 0 0.0.0.0:68 0.0.0.0:* 413/dhclient
udp 0 0 0.0.0.0:111 0.0.0.0:* 398/rpcbind
udp 0 0 192.168.1.4:123 0.0.0.0:* 412/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 412/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 412/ntpd
udp 0 0 127.0.0.1:601 0.0.0.0:* 425/rpc.statd
udp 0 0 0.0.0.0:60222 0.0.0.0:* -
udp 0 0 0.0.0.0:982 0.0.0.0:* 398/rpcbind
udp 0 0 127.0.0.1:1021 0.0.0.0:* 421/rpc.statd
udp 0 0 127.0.0.1:1022 0.0.0.0:* 422/rpc.statd
udp 0 0 0.0.0.0:52292 0.0.0.0:* 425/rpc.statd
udp 0 0 0.0.0.0:40166 0.0.0.0:* 422/rpc.statd
udp 0 0 0.0.0.0:61162 0.0.0.0:* 413/dhclient
udp 0 0 0.0.0.0:51055 0.0.0.0:* 421/rpc.statd
udp6 0 0 :::111 :::* 398/rpcbind
udp6 0 0 fe80::fad1:11ff:fe0:123 :::* 412/ntpd
udp6 0 0 ::1:123 :::* 412/ntpd
udp6 0 0 :::123 :::* 412/ntpd
udp6 0 0 :::47533 :::* 413/dhclient
udp6 0 0 :::43513 :::* 425/rpc.statd
udp6 0 0 :::59956 :::* 421/rpc.statd
udp6 0 0 :::982 :::* 398/rpcbind
udp6 0 0 :::44073 :::* 422/rpc.statd
udp6 0 0 :::58923 :::* -
[handy@jarmano ~]$
Message 5 of 12
handy1
Aspirant

Re: NTP-Server & Firewall port settings:

I made the firewall settings such that the ntp service is using the UDP protocol for both IN & OUT & now I get the following which is certainly an improvement, as at least now the delay, offset & jitter numbers look to be behaving as they should (instead of all being zero). But now I've got this:

NTP synchronized: no
RTC in local TZ: no


when I use my time alias - the command follows:

alias time='timedatectl status && ntpq -c lpeer'


Here is the output from the above alias:

[handy@jarmano ~]$ time
Local time: Fri 2013-03-08 19:28:45 EST
Universal time: Fri 2013-03-08 08:28:45 UTC
RTC time: Fri 2013-03-08 08:28:46
Timezone: Australia/Sydney (EST, +1100)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
Sun 2012-10-07 01:59:59 EST
Sun 2012-10-07 03:00:00 EST
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2013-04-07 02:59:59 EST
Sun 2013-04-07 02:00:00 EST
remote refid st t when poll reach delay offset jitter
==============================================================================
*192.168.1.15 83.170.1.42 3 u 52 64 1 0.465 7.278 6.586


I still have the 90 second delay on boot too...
Message 6 of 12
handy1
Aspirant

Re: NTP-Server & Firewall port settings:

I've let some time go by & it looks like the Duo is working properly with the above mentioned settings:

IN & OUT UDP & calling the ntp service rather than port 123.

I still have the 90 second delay at boot, which is of course a drag...
Message 7 of 12
handy1
Aspirant

Re: NTP-Server & Firewall port settings:

I ended up deleting the gufw rules & then using a small run once config file which setup just the basics for ufw & of course ntp. Then I added my incoming rules via gufw ('cause its so easy).

It works.

Now when I boot I wait for ~ 8 seconds instead of 90 seconds whilst ntp sorts itself out.

Here is a copy of my script called my_ufw.conf.sh

#!/bin/sh
#######################################################################
# Run this script only once, to setup your UFW - uncomplicated firewall
#######################################################################

# disable firewall
ufw disable

# reset all firewall rules
ufw reset

# set default rules: deny all incoming traffic, allow all outgoing traffic
ufw default deny incoming
ufw default allow outgoing

# open ports for Transmission-Daemon
ufw allow 9091
ufw allow 20500:20599/tcp
ufw allow 20500:20599/udp

# open port for GIT
ufw allow 9418/tcp

# open port for network time protocol (ntpd)
ufw allow ntp

# enable firewall
ufw enable

# list all firewall rules
ufw status verbose


Add the following incoming rules, using the In drop down menu option in gufw:

993 TCP = IMAP
143 TCP & UDP
110 TCP = POP3
22 TCP = SSH
9418 TCP = GIT
Message 8 of 12
StephenB
Guru

Re: [SOLVED] NTP-Server & Firewall port settings:

I don't think the added incoming rules are needed for NTP (which AFAIK only needs UDP port 123). I suspect its the "allow ntp" command that is solving the problem (assuming the 90 second start up issue was all because of NTP, and not due to some other services).

Anyway, I'm glad its sorted out. Thx for sharing your solution.
Message 9 of 12
handy1
Aspirant

Re: [SOLVED] NTP-Server & Firewall port settings:

Hi StephenB,

Having thought about it (more sub-consciously than anything) overnight, I think that what actually took away the problem was allowing all outgoing packets on the network. Which I did in the run once setup script - my_ufw.conf.sh

I haven't really looked at it yet, but I'm thinking that the restrictions that I'd placed on the outgoing packets weren't correct.

I did add the following outgoing rules via gufw:

80 TCP = HTTP
53 UDP = DNS
443 TCP = HTTPS
21 TCP = FTP
465 TCP = SMTP
25 TCP = Insecure SMTP
22 TCP = SSH
993 TCP & UDP = IMAP
143 TCP & UDP = Insecure IMAP
9418 TCP = GIT

I had also allowed ntp both incoming & outgoing on port 123 using UDP, but there was that delay...

I guess I could test the theory by scrapping all the current rules & adding the previously mentioned rules via gufw making sure to allow all outgoing packets.
Message 10 of 12
StephenB
Guru

Re: [SOLVED] NTP-Server & Firewall port settings:

handy wrote:
I guess I could test the theory by scrapping all the current rules & adding the previously mentioned rules via gufw making sure to allow all outgoing packets.
On the other hand, it is now working nicely... 😄
Message 11 of 12
handy1
Aspirant

Re: [SOLVED] NTP-Server & Firewall port settings:

I know, that has definitely occurred to me too. lol

If I get brave I'll test it out & post the results here. 😄
Message 12 of 12
Discussion stats
  • 11 replies
  • 15679 views
  • 0 kudos
  • 2 in conversation
Announcements