NTP problems.

  • Thread starter Deleted member 46272
  • Start date
D

Deleted member 46272

Guest
I have a few dumb devices (Gemtec IoT LoraWAN gateways) on one network that rely on NTP to function correctly. After they were installed, they worked for about 1 day then stopped relaying sensor info to their cloud dashboard. I looked at traffic logs, saw a relentless wall of attempts by the device IPs to connect to a varied list of IPs over NTP. I came to the conclusion that the AT&T Broadband circuit at the site was the culprit, (AT&T seems to block NTP, along with a bunch of other stuff https://about.att.com/sites/broadband/network ), so I've asked the firewall (Fortigate 60E or 60F) engineers to tunnel NTP traffic out via the management IPSEC tunnel through their NOC to bypass AT&T. They insist that they have created this policy route, yet the devices are still continuously hammering at a long list of IPs via UDP port 123 and still not working. I don't have rock-solid faith in the firewall engineers (outsourced 3rd party), so it could be that they did not create the policy route correctly, but I don't know how to test for this.

I thought that since the device firmware were Linux-based that they would respect DHCP Option 42, so I had an NTP instance fired up locally on the firewall and enabled option 42 to push that IP, but the devices seem to ignore it. I have not seen a single attempt by a device to try NTP against the firewall's IP.

I rolled up my sleeves and did a packet capture.
What I'm seeing is that:
  • All NTP server responses have NULL Reference IDs and NULL Reference Timestamps
  • Origin Timestamps have random timestamps.
Sample screenshot below.

Why am I seeing nulls in the server responses?
I think, but am not sure, that the random "Origin" timestamps are a security "feature" implemented by the "chrony" NTP implementation. Is that a valid interpretation?

I see the same pattern for all NTP queries from a large number of server IPs, so its unlikely to be a broken server or server cluster, especially less likely for it to be something broken at *.pool.ntp.org
I don't have access to a PC at the site or a way to VPN into the site to test with a different device type, unfortunately.

The Gemtec devices are dumb pieces of crap with shoddy firmware, but we do have probably a thousand of them them deployed at hundreds of other sites and I have NOT seen this failure mode before. This site has 3 of them, and they are all exhibiting this behavior.

1697671930766.png
 
Last edited by a moderator:

alcachofas

Wise, Aged Ars Veteran
109
Subscriptor
I’m a little confused what your firewall folks have done.

Have they…

…changed it so that any outbound traffic to anywhere on port 123 gets routed out successfully

…or made a forwarding rule so that traffic for <firewall_ip>:123 can get out?

I’d assumed the first until you started pushing out dhcp options.

I’d ignore dhcp, and assume the crappy devices have a hardcoded list of servers to hit, and just pick one server they’re actively trying to get to. Can you test outbound udp conns to that?
 
D

Deleted member 46272

Guest
They set up an NTP server with the DHCP option, then when that didn't work, they tried to set up a policy route to route NTP traffic out via a VPN tunnel. It turns out that they made a routing mistake and NTP traffic was not making it out via the tunnel successfully. Once they fixed that (this morning) I started seeing healthy NTP traffic and the system started working.
I've learned a bit about NTP, so it wasn't a total waste of time.
 
I have AT&T fiber and NTP seems to work fine...


Code:
C:\Users\david>w32tm /stripchart /computer:time.google.com
Tracking time.google.com [[2001:4860:4806:8::]:123].
The current time is 10/19/2023 3:36:05 PM.
15:36:05, d:+00.0158207s o:-00.5892350s  [                         * |                           ]
15:36:07, d:+00.0168553s o:-00.5894505s  [                         * |                           ]
15:36:09, d:+00.0172224s o:-00.5888643s  [                         * |                           ]
15:36:11, d:+00.0215541s o:-00.5913784s  [                         * |                           ]
^C

C:\Users\david>w32tm /stripchart /computer:us.pool.ntp.org
Tracking us.pool.ntp.org [162.159.200.1:123].
The current time is 10/19/2023 3:36:54 PM.
15:36:54, d:+00.0063559s o:-00.5940518s  [                         * |                           ]
15:36:56, d:+00.0071769s o:-00.5941323s  [                         * |                           ]
15:36:58, d:+00.0081373s o:-00.5943405s  [                         * |                           ]
15:37:00, d:+00.0070273s o:-00.5942360s  [                         * |                           ]

If I'm reading their Network Practices doc that OP linked correctly, it seems they block incoming requests on port 123, so you can't run your own NTP server open to the internet. But accessing an NTP server on the internet shouldn't be an issue. Do you know how it gets the IPs it is trying to reach? Maybe it has old firmware that is looking for someone's NTP service that doesn't exist anymore.
 
Last edited:

spiralscratch

Ars Praefectus
3,105
Subscriptor
If I'm reading their Network Practices doc that OP linked correctly, it seems they block incoming requests on port 123, so you can't run your own NTP server open to the internet. But accessing an NTP server on the internet shouldn't be an issue. Do you know how it gets the IPs it is trying to reach? Maybe it has old firmware that is looking for someone's NTP service that doesn't exist anymore.

According to the table it's blocked in- and outbound:

Port

Transport

Protocol

Direction

Threats

123

UDP

NTP

Both

Reflective DDOS
 

w00key

Ars Legatus Legionis
10,103
Subscriptor
Meh NTP floods are a serious threat nowadays with shitty firmware. Newer amplification attacks are better but it is still used.

Sounds like AT&T doesn't block it outright, only when it goes over a theshold tripping flood detection.


I would have setup an internal NTP server and let it sync to pool.ntp.org, and with a firewall you can just rewrite all requests to whatever:123 to your own internal one. Just like whatever:dns, you often want to filter them and for guest/shitty firmwares, reroute them to security focussed, malware/phishing blocking upstream DNS server like Quad9.
 
  • Like
Reactions: alcachofas
D

Deleted member 46272

Guest
Sounds like AT&T doesn't block it outright, only when it goes over a threshold tripping flood detection.
Probably, or there could be regional differences, or it may depend on the actual CPE device you get. Who knows.
I would have setup an internal NTP server and let it sync to pool.ntp.org, and with a firewall you can just rewrite all requests to whatever:123 to your own internal one. Just like whatever:dns, you often want to filter them and for guest/shitty firmwares, reroute them to security focussed, malware/phishing blocking upstream DNS server like Quad9.
But that would require firewall engineers that are actually, you know, competent and actually care. This vendor can't even set up a DHCP reservation and, instead, close the ticket out with a note stating that my reservation request is out of DHCP scope. So I have to open another ticket to add a DHCP scope to cover the IPs I need in the reservation (sometimes for a single IP), then once that is done, open another ticket again to set up the reservation becuase the "engineers" apparently can't figure out how to do these 2 steps themselves. When they set up that tunnel for bypassing NTP around AT&T's block, they never bothered to check to see if traffic was actually hitting their initial policy route that dumped NTP into the tunnel. There are 2 or 3 simple and easy ways to check this right in the GUI and it takes all of 5 seconds to get to that screen and you get a real-time view of the mount of traffic hitting the rule.
I'm very often stuck between idiot Operations people who can't follow simple directions, device vendors that are unhelpful and send garbage hardware and no documentation, service vendors who don't give a F***, and ISPs who do unfathomable things. Some weeks are better than others, but I've been wishing for this week to be over since about 11AM on Monday and it hasn't gotten better.
 
  • Haha
Reactions: Arty50

sryan2k1

Ars Legatus Legionis
46,882
Subscriptor++
I'm trying to get over the fact that ATT is purposely blocking NTP. It's one of the most important basic protocols now, and even the most basic home network will have myriad devices reliant on it (each probably using a unique set of addresses). I've never heard of an ISP doing this.

NTP is super insecure and ripe for abuse, it's sane of them to block it.


No(*) consumer device relies on NTP directly. They'll use HTTP(s) to their own cloud services for time delivery and not raw NTP.
 

malor

Ars Legatus Legionis
16,093
So you can't configure these devices to use your own NTP server? If not, their firmware is well beyond lousy. For future purchases, I would strongly recommend buying something else.

Blocking all NTP, IMO, is a ridiculous solution by AT&T. Not blocking anything would be a primary spec requirement for me in buying business connectivity. It makes sense for home service, but never on a commercial contract.
 
  • Like
Reactions: ColinABQ

spiralscratch

Ars Praefectus
3,105
Subscriptor
No(*) consumer device relies on NTP directly. They'll use HTTP(s) to their own cloud services for time delivery and not raw NTP.

Yeah, no:

How the Windows Time Service Works said:
The Windows Time service communicates on a network to identify reliable time sources, obtain time information, and provide time information to other computers. It performs this communication as defined by the NTP and SNTP RFCs.

Port Assignments for the Windows Time Service

Service nameUDPTCP
NTP123N/A
SNTP123N/A
https://learn.microsoft.com/en-us/w...ks#network-ports-used-by-windows-time-service

TCP and UDP ports used by Apple software products said:
PortTCP or
UDP
Service or
protocol name
RFCService nameUsed by
80TCPHypertext Transfer Protocol (HTTP)2616httpWorld Wide Web, FaceTime, iMessage, iCloud, Maps, Apple Music, iTunes Store, Podcasts, Mac App Store, Backup, Calendar, WebDAV, AirPlay, macOS Internet Recovery, Xcode Server (Xcode app, hosted and remote Git HTTP, remote SVN HTTP)
123UDPNetwork Time Protocol (NTP)1305ntpDate & Time preferences, network time server synchronization, Apple TV network time server sync
443TCPSecure Sockets Layer (SSL or HTTPS)2818httpsTLS websites, iTunes Store, Software Update, Spotlight Suggestions, Mac App Store, Maps, FaceTime, Game Center, iCloud authentication and DAV Services (Contacts, Calendars, Bookmarks), iCloud backup and apps (Calendars, Contacts, Find My iPhone, Find My Friends, Mail, iMessage, Documents & Photo Stream), iCloud Key Value Store (KVS), AirPlay, macOS Internet Recovery, Dictation, Siri, Xcode Server (hosted and remote Git HTTPS, remote SVN HTTPS, Apple Developer registration), Push notifications (if necessary)
https://support.apple.com/en-us/HT202944

Time Overview | Android Open Source Project said:
There are two main time detection origins configured for use by default in AOSP:
  • Network: Uses Network Time Protocol (NTP) time servers.
  • Telephony: Uses Network Identity and Time Zone (NITZ) telephony signals.
Both telephony and network origins require connectivity to external networks, which are not always available.

Starting with Android 12, Android also supports the following origins, which are not configured for use by default:
  • GNSS: Uses the GPS location provider to obtain a time from a GNSS source.
  • External: Generic origin that allows device manufacturers to integrate their own source of Unix epoch time.
https://source.android.com/docs/core/connect/time

That's the big three right there. All use NTP, none HTTP, for time services. Not to mention every consumer router and other network-attached devices that commonly have specific configuration fields for NTP. I've never heard of using HTTP for getting the current time with any real accuracy.
 

malor

Ars Legatus Legionis
16,093
That's the big three right there. All use NTP, none HTTP, for time services. Not to mention every consumer router and other network-attached devices that commonly have specific configuration fields for NTP. I've never heard of using HTTP for getting the current time with any real accuracy.
I vaguely remember Microsoft using HTTPS for initial time setting, by re-using an HTTP data field that was frequently set to a time value, when the spec actually wanted a random number. The people writing the time service decided to use this value when they couldn't reach an NTP server, and it ended up causing real havoc in some networks, because some HTTPS implementations actually did use a random number in that field.

Microsoft definitely tried to use HTTPS for setting the date and time. And it was even pretty accurate, as long as you were talking to the right kind of server. But, um, bugs.

edit: this was just fixed within the last year or so, it's pretty recent.
 
D

Deleted member 46272

Guest
So you can't configure these devices to use your own NTP server? If not, their firmware is well beyond lousy. For future purchases, I would strongly recommend buying something else.
I agree 100%, but I have no say in the matter, I just have to make it work. It's lousy for many other reasons as well - this is probably the most mild. It also has more bugs than an entomologist convention.
I isolate this garbage on it's own VLAN, along with a pile of other crap that vendors shove out the door. We have thousands of small, isolated networks that are all unique in size, network layout, and mix of systems , so although we have some level of standardization, it's impossible to lock things down 100%, and I only have loose authority into how the networks are configured and none whatsoever in what crap gets deployed on the networks.

Most systems that we deploy are perfectly fine without NTP access. Out of probably 100+ different kinds of systems and devices I deal with (PCs, PoS systems, camera systems, door access, FACP, appliances of all kinds, etc), this is the first system that actually fails to function. Most sync time some other way, allow for time to be set manually and work fine afterwards, or it just doesn't matter. This is the first time I see a device actually fail to function at all without it and has a hard-coded list of public NTP servers with no way to override.
 
Last edited by a moderator:

alcachofas

Wise, Aged Ars Veteran
109
Subscriptor
I vaguely remember Microsoft using HTTPS for initial time setting, by re-using an HTTP data field that was frequently set to a time value, when the spec actually wanted a random number. The people writing the time service decided to use this value when they couldn't reach an NTP server, and it ended up causing real havoc in some networks, because some HTTPS implementations actually did use a random number in that field.

Microsoft definitely tried to use HTTPS for setting the date and time. And it was even pretty accurate, as long as you were talking to the right kind of server. But, um, bugs.

edit: this was just fixed within the last year or so, it's pretty recent.
Ha. I remember this one. Wasn’t the symptom that windows server clocks were occasionally jumping by like 10 years for no obvious reason? Excellent bug
 

w00key

Ars Legatus Legionis
10,103
Subscriptor
Botnets use outgoing NTP to spam a misconfigured NTPD to DDOS. ISPs don't like that.

Although ISPs can fix this themselves too, using something like the rpf-check config statement in Juniper. They are just sooooo slow in implementing any kind of spoof protection or BGP security, blocking NTP (after threshold triggered) is an easier fix for a common headache.
 

Paladin

Ars Legatus Legionis
33,855
Subscriptor
Yup that is basically what I was thinking, limit at the firewall so only servers you want to allow are allowed. Prevents participation in a DDoS, unless it happens to target one of those servers.

Of course, patching your stuff also helps with that. ;) Hard to do on some IoT devices but you can usually also toss those in the recycle pile without too much pain, after a while.
 

malor

Ars Legatus Legionis
16,093
True, but accurate time never hurts. It can be handy in forensic investigations of logs after a hack, for instance. If everything on the network has the correct time, then it can be easier to reconstruct what happened. Admittedly, that's pretty esoteric.

I've always liked having accurate time on any network I've been responsible for, but away from my unwarranted control-freakishness, anything within a minute or so is generally fine. But with me, even on my home network, I have an NTP server, and all the machines sync to it.
 

teubbist

Ars Scholae Palatinae
1,127
But is the firewall a reliable ticker?

Just pointing NTP at the next hop(or closest PE) is one of those weird habits that I've never really understood. There's still a surprisingly large number of network devices out there that only implement SNTP or NTP-that-acts-like-SNTP and will happily wrench the clock around. And have poor time keeping as a bonus to make those wrenchs extra big.

And then you get virtualized versions where some vendors seem to have zero'd in on the crappiest emulated timing source(i.e PIT) and called it good.
 

malor

Ars Legatus Legionis
16,093
Aiming all your clients at pool.ntp.org (or time.windows.com) will definitely work well enough for almost anyone, but generates a lot more NTP traffic and load on those servers, as well as traffic on your network pipe. A better approach, IMO, is using one or two internal machines to pull in outside time, and then having all your clients talk to that machine or machines instead. (that is, of course, assuming that your clients are configurable.)

Most PCs have reasonably good clocks. Using ntpd or openntpd, and syncing an internal server to a couple of low-ping public NTP servers, will measure its drift over time, and will ultimately keep that PC quite close to reality, even after a fairly extended period (weeks) without network service.

This kind of setup costs almost nothing, and will keep quite good time.
 

iljitsch

Ars Tribunus Angusticlavius
9,637
Subscriptor++
Most PCs have reasonably good clocks.
Are you sure? My MacBook Pro has had times where it was off by a minute or so and apparently NTP stopped working until a reboot.

And my first iPhone (3G in 2008) also had its time drift and for some inexplicable reason the GUI for manually adjusting the time that was in iOS at the time wasn't present on my particular iPhone.

It seems to me that current computers don't have very accurate clocks because with NTP and ubiquitous networking they don't have to.
 

malor

Ars Legatus Legionis
16,093
The last time I was really looking, most PCs had drift rates of 7 to 15 parts in a million, which translates to about 18 to 40 seconds a month. And then either NTP or OpenNTP will compute that drift rate over time, and store the value in the filesystem. If they lose contact with NTP servers, they'll keep applying the drift corrections locally, so they'll stay reasonably close.

The server "chrony" apparently also tries to track and account for temperature changes; per that programmer, many onboard chips change their drift rate as they heat up. That implies that you would typically want to use a local source that stays at about the same temp all the time, or else maybe use chrony to try to compensate. It's meant for machines that have crappy internet access, which is where you'd want good local time, or for machines that are turned on and off a lot.

As far as your Macbook goes, I have no idea what Apple does about time. I know how things work on Linux, but not the internals of either MacOS or Windows. With Windows, I just know how to sync client machines to my NTP server. I don't remember even that much about MacOS. I've done it, but I've long since forgotten how. I haven't had a Mac in years.

Since I only use Linux boxes as NTP sources, that's the only thing I've ever paid much attention to. I'm sure the BSDs would work similarly, I just haven't used those for serving time.

edit with an example: my NTP server has a drift rate of -8.016, per openntpd. I believe that means it natively loses about 20 seconds a month. The motherboard was bought new in 2014.

second edit: the brand-new Moginsok firewall I'm using has a drift of 14.455. That chipset is just from the last couple of years, I think.

third edit: a Zen 3 machine, from Dell, has a drift of 3.247, or just 8.6 seconds of gain per month. I've never seen a figure that low before, which implies that maybe onboard clocks are improving, or at least that AMD is doing them better. That machine was from early 2022, I think.
 
Last edited:
i am using chronyd on fedora as my time servers. anywhere i can configure things to use my local time servers, i do. i have anycast IPs configured on 3 boxes all serving NTP. i allow NTP access to my servers, but also allow calls to external NTP in the iptables policy. then, i DNAT the outbound NTP call and point it at my servers. with iptables, the DNAT happens after the firewall policy evaluates. honestly, this has been working for quite some time.

i believe my cisco sg500/300 switches use sntp, which i point at my NTP servers, and that works too. personallly, i think having my own NTP servers and pointing clients at them keeps things orderly. i dont really care about nanosecond precision or whatever, as long as everything agrees on what time it is. the most significant need i have for NTP is kerberos, which needs to be within drift.
 

iljitsch

Ars Tribunus Angusticlavius
9,637
Subscriptor++
IMO anything in excess of two minutes slow or fast is unacceptable. So for anything that doesn't sync to NTP or GPS the drift has to be less than 120 seconds in 7 months (the max between daylight changes here) so more like 15 seconds per month than 40 seconds per month.

(Yay! Getting to set the time on 4 devices this weekend...!)
 
D

Deleted member 46272

Guest
At corporate scale, buying a dedicated local NTP server is pretty cheap. I believe you can get ones that use GPS as a source for about $1500. And then as @sryan2k1 is saying, you can just transparently reroute all traffic to port 123 to that box instead.
This doesn't scale at all when you have thousands of very small independent locations. I work in retail, mainly corporate cafes and similar type of services - most sites have 2-5 PoS systems, a PC or two, a timeclock, and an IoT sensor deployment. There are no servers at the sites. There are dozens of different PoS systems in use, some sites even have a mix, so there is no real standardization because the tech at the site depends heavily on the client's requirements.
Sound like the best thing would be to NAT port 123 traffic, point that at the firewall's NTP server, and have the firewall itself sync to ntp.pool.org. However, the MSP has resisted our requests to NAT DNS traffic (we've had issues with ISP DNS filtering at sites - in many cases, our "ISP" are via our client's network) so I won't hold my breath on this.