Getting time from local machine using ntp

Hi, i'm using OpenWrt 18.06.2 on netgear r6220 router. I'd like to synchronize its time with my laptop, because when i boot my device it wont get internet access before it has proper time(I use wireguard so that everything is blocked before its up). So I have to manually log into luci and synchronize clock with browser. This is not a big problem to me.:slightly_smiling_face:

I've set my laptop to act as ntp- server(and set my firewall settings) and on my router I'd like to use like: ntpd -p , but is has no effect. My laptop is on the same lan as router.

I tried to create a static route to my local machine but it caused luci to freeze and couln't access anymore to it via luci or ssh. (Internet, however was up also after restarting my router on normal mode?) So I used filesave mode and reverted changes. I surely don't understand enough on this sort of things. Next time I'll look at a router that has a hardware clock to avoid this problem.

Any suggestions are appreciated. Thanks!

Add your laptop as a NTP Candidate (server) in Luci System Page in General Settings under Time Synchronization.

3 Likes

I don't believe your issue is time, per se. Nonetheless, @mbo2o described how to add your laptop as an NTP server. I hope it works for you.

Thanks, that I didn't remeber to do. I added my laptop s NTP candidate but did't manage to use my ntp server. Maybe I'll give up for now.

  • What do you mean by the phrase "but did't manage to use my ntp server"?
  • And if you didn't remember to add you laptop as an NTP server...what did you do?
  • How will your computer get time if your router doesn't have Internet?

As a bit of advice, you can configure the IP of one or two NTP servers to use the WAN route, therefore you can get time from the Internet before the WG interface comes up.

1 Like

First on my router I set my time a bit backwards using date command. Then tried to correct it using ntpd -p my-local-machine-ip. This didn't change my system time. I had set my laptop as a server before that using luci.

Sorry I remember wrong. I actually did this before. I also set my windows laptop to run as ntp server.

To get time I use luci's 'sync with browser' button.
Thanks for your advice. I'll look at that creating route method. At this time it's enough for me that I can sync the time via browser.

1 Like

I understood that...and I think you missed my point...if there's no Internet, where would the the computer upon which you hit the button - get an NTP connection.

I hope one of the suggestions above works for you. Let us know your results.

All x86 computers have an internal RTC with a battery, you don't need a NTP server.

I don't know if this is accurate enough for Wireguard but it's usually enough for most applications.

That's not a common feature in consumer routers afaik.

You can make your own local NTP server with a Raspberry or similar device that exposes GPIO pins where you can connect a RTC module.

Not all (or dead battery). And in addition, that was my point, that the PC may be unsysnced. Also, I've found no proof yet that Wireguard requires the current time. It does need entropy, though.

You're also forgetting, that the OP needs the same down Internet connection for the PC to connect to its NTP server.

I have a device with an RTC, it still needs to get time via NTP (no battery). It's commonly assumed that a router connects somewhere, and hence can reach an NTP server.

That's very very weird, and a situation that is highly inconvenient.
In PC/server hardware I know you need a battery to keep the BIOS/UEFI settings.

With a dead battery you lose BIOS settings if you power down and pull the plug. Which means that a power outage will reset your BIOS.

Unsynced from what. Onboard RTCs aren't atomic clocks but that's still high-precision quartz clocks, they take ages to go appreciably out of sync for normal computer tasks.

Yes it does need entropy. Most VPNs do need entropy. This was also reported also in GL-inet forums (they use OpenWrt as base for their firmware, and apparently they also use the same forum software as OpenWrt) https://forum.gl-inet.com/t/wireguard-and-entropy/5889

Devices with a working battery-backed RTC will use that to get the correct time. NTP is only used to adjust the RTC every now and then.

1 Like

I got the time syncing by adding a few routes to ntp-servers on internet. Wireguard works now automatically after booting. Thanks @lleachii!

I cant find any evidence that my router has an internal RTC. In kernel log is says somethin like:
[5.319240] hctosys: unable to open rtc device (rtc0)
Didn't find any rtc module or configuration files installed.

The "x86 computers that always have a RTC" are PCs, mini-PCs or laptops. Intel or AMD or VIA CPUs.

The "x86" is the CPU architecture name.

Your netgear 6220 is using a CPU of "ARM" or "mips" architecture. These devices don't usually have a hardware-backed RTC, or an RTC at all as they are designed for maximum cheapness in mind.

After all, your router didn't need a clock to work fine on stock firmware.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.