DDWRT Losing Time Of Day (TOD)

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> General Questions
Goto page 1, 2  Next
Author Message
gil_happy
DD-WRT User


Joined: 24 Sep 2009
Posts: 105

PostPosted: Mon Jun 25, 2018 23:08    Post subject: DDWRT Losing Time Of Day (TOD) Reply with quote
Hello, with the great help of everyone, I previously setup a VPN solution between 2 locations and it has mostly been working great. Here are the threads:

- https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=307318&highlight=
- https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=313143&highlight=

The problem is that the 'Primary Home (router2)' keeps losing it's time of day (TOD). When I telnet to 192.168.1.2 and type the 'date' command, I see that it is 'Jan 1970'. Because of this, my VPN stops working. Rebooting or resetting the router seems to fix the problem. From the uptime of the router, I can see that the router has been up for approximately 7 days, and has lost its TOD at some point.

Does anyone know how to fix? The 'Primary Home (router1)' does not have a problem and never loses its TOD. I have attached a screen shot from 'Primary Home (router2)' with the network settings.

Thanks in advance!
Sponsor
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 8034

PostPosted: Tue Jun 26, 2018 4:24    Post subject: Reply with quote
I have seen a few builds where the date/time is never updated upon bootup (for reasons unknown). And never seems to get updated later either. But I've never seen a case where once updated, it suddenly returned to Jan 1, 1970, other than the result of a reboot.

The only thing I can suggest is the following script, which initializes the date/time once the WAN comes up, then schedules a job to periodically update the date/time.

https://pastebin.com/cW2j7z6m

Make sure JFFS is enabled. Copy and paste the entire script into a shell window (telnet/ssh), hit enter, and it will automatically install. If you need to make changes, you can use the vi editor.

Code:
vi /jffs/etc/config/set-datetime.wanup


But if the date/time is just spontaneously resetting to Jan 1, 1970 for some reason, then this script will probably not solve the problem, at least if it can't be updated before the cert needs to be validated again.
gil_happy
DD-WRT User


Joined: 24 Sep 2009
Posts: 105

PostPosted: Tue Jun 26, 2018 13:33    Post subject: Reply with quote
Thanks very much for this info eibgrad... a couple of things; on the affected router (Primary Home router2), I am not using the WAN port - only the LAN port (LAN to LAN). Also, per your suggestion in the original thread, we selected the option to 'assign the WAN to the LAN'. Knowing this information, do you suggest, or rather, will the script work?
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 8034

PostPosted: Tue Jun 26, 2018 13:45    Post subject: Reply with quote
The script is NOT dependent on having an active WAN. It's only dependent on having internet access on that device. And that's possible in a bridged (LAN to LAN) configuration so long as you specify a gateway IP and DNS server in the Router IP section. When the WAN is disabled, the router no longer has access to those settings from the upstream router, so *you* have to make sure to provide them. And at least according to the image you posted, it appears you have. Which begs the question, then why isn't it updating the date/time? As I said, I have seen this before, but I'm just not sure why things go wrong. So the script may help.
gil_happy
DD-WRT User


Joined: 24 Sep 2009
Posts: 105

PostPosted: Tue Jun 26, 2018 13:52    Post subject: Reply with quote
eibgrad wrote:
The script is NOT dependent on having an active WAN. It's only dependent on having internet access on that device. And that's possible in a bridged (LAN to LAN) configuration so long as you specify a gateway IP and DNS server in the Router IP section. When the WAN is disabled, the router no longer has access to those settings from the upstream router, so *you* have to make sure to provide them. And at least according to the image you posted, it appears you have. Which begs the question, then why isn't it updating the date/time? As I said, I have seen this before, but I'm just not sure why things go wrong. So the script may help.


Thank you... I will try the script on Friday once I'm back in front of the routers.
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 2722
Location: UK, London, just across the river..

PostPosted: Tue Jun 26, 2018 14:55    Post subject: Reply with quote
well i tried this script instead Razz and on my R7800 & R7000 it gets stuck by connecting to NTP server, tried with few others but no avail..no internet access at all..
do i have to disable the GUI NTP option first...??
also they are 2 scripts so its better to do them one by one via CLI otherwise copy paste its funny but i guess it works,
could you do it via GUI commands field ? (have to remove all "")....
i do have a jffs on NTFS USBflash drive and i can see this file created and can edit it with vi....

_________________
Atheros
TP-Link WR740Nv1 ------ DD-WRT 33772 BS WAP/Switch (wired)
TP-Link WR1043NDv2 ------DD-WRT 40009 BS (AP,PPPoE,NAT,AD Blocking,AP Isolation,Firewall,Local DNS,Forced DNS,DoT)
TP-Link WR1043NDv2 ------DD-WRT 40784 BS (AP,NAT,AD Blocking,Firewall,Wi-Fi OFF,Local DNS,Forced DNS,DoT)
TP-Link WR1043NDv2.......... Gargoyle OS 1.11.0 (AP,NAT,QoS,Quotas)
Qualcomm/IPQ8065
Netgear R7800 ------------DD-WRT 40270M 4.9 Kong (AP,NAT,AD-Blocking,AP&Net Isolation,Firewall,Local DNS,Forced DNS,DNSCrypt v2 x2)
Broadcom
Netgear R7000 ---------DD-WRT 40270M Kong (AP,NAT,AD-Blocking,Firewall,Local DNS,Forced DNS,DoT)
----------------------------------------------------------------------------------------------------
Stubby for DNS over TLS I DNSCrypt v2 via Entware by mac913
gil_happy
DD-WRT User


Joined: 24 Sep 2009
Posts: 105

PostPosted: Thu Jun 28, 2018 16:08    Post subject: Reply with quote
As mentioned in my last post, I hope to try the script tomorrow afternoon sometime. Also, in my original post, I didn't mention I have the NTP client enabled (see attached pic). I'm not sure if this could be part of the problem? Meaning, should I try disabling this for a couple of weeks 'before trying the script' to see if I still lose TOD with the NTP client disabled?
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 2722
Location: UK, London, just across the river..

PostPosted: Fri Jun 29, 2018 4:50    Post subject: Reply with quote
i can tell you that something is not wright with your setup just by looking at this picture posted...
also stop asking a questions that nobody can answer...
its you to test and report....

_________________
Atheros
TP-Link WR740Nv1 ------ DD-WRT 33772 BS WAP/Switch (wired)
TP-Link WR1043NDv2 ------DD-WRT 40009 BS (AP,PPPoE,NAT,AD Blocking,AP Isolation,Firewall,Local DNS,Forced DNS,DoT)
TP-Link WR1043NDv2 ------DD-WRT 40784 BS (AP,NAT,AD Blocking,Firewall,Wi-Fi OFF,Local DNS,Forced DNS,DoT)
TP-Link WR1043NDv2.......... Gargoyle OS 1.11.0 (AP,NAT,QoS,Quotas)
Qualcomm/IPQ8065
Netgear R7800 ------------DD-WRT 40270M 4.9 Kong (AP,NAT,AD-Blocking,AP&Net Isolation,Firewall,Local DNS,Forced DNS,DNSCrypt v2 x2)
Broadcom
Netgear R7000 ---------DD-WRT 40270M Kong (AP,NAT,AD-Blocking,Firewall,Local DNS,Forced DNS,DoT)
----------------------------------------------------------------------------------------------------
Stubby for DNS over TLS I DNSCrypt v2 via Entware by mac913
gil_happy
DD-WRT User


Joined: 24 Sep 2009
Posts: 105

PostPosted: Fri Jun 29, 2018 21:46    Post subject: Reply with quote
Ok, after trying out the script this afternoon, it does not appear to work. With the script in place, and even after rebooting the router, the date on the 'PHrouter2' shows Dec 31, 1969 (previously, if I just rebooted the router with no script, it would update the time to the current TOD for a short period of time). Here is what I did:

- first, I went into the web GUI (Setup, Basic Setup), and disabled the NTP client. As mentioned initially, the NTP client has always been enabled.
- then went into Administration, Management and enabled JFFS2 Support (enable 'Internal Flash Storage'). I also enabled the 'Clean Internal Flash Storage' per the wiki (https://wiki.dd-wrt.com/wiki/index.php/Journalling_Flash_File_System)
- I also changed the NTP server from 'time.apple.com' to 'pool.ntp.org'

A couple of things:

- how does the script know about the time offset?
- also, from looking at line 18 and 20, since in the original solution, this device never gets a WAN IP address (this is part of the working solution provided), it seems like this script will never work. When I type 'nvram get wan_gateway' from the CLI, it returns 0.0.0.0.
tatsuya46
DD-WRT Guru


Joined: 03 Jan 2010
Posts: 7010
Location: Winnipeg, Canada

PostPosted: Fri Jun 29, 2018 21:56    Post subject: Reply with quote
known issue, ddwrt cant handle setting a date/time manually, it depends on having wan. dont ask why.
_________________
LATEST FIRMWARE(S) || Qualcomm Atheros Wi-Fi Settings Guide || Qualcomm Atheros Repeating

[QUALCOMM] R7800 ---------------> DD-WRT v3.0-r40270M kongat
[QUALCOMM] DIR-862L ------------> DD-WRT v3.0-r40784 std
[QUALCOMM] WNDR4300 v1 ------> DD-WRT v3.0-r40784 std
[QUALCOMM] DIR-862L ------------> DD-WRT v3.0-r40784 std
▲ ACTIVE / INACTIVE ▼
[BROADCOM] DIR-860L A1 --------> DD-WRT v3.0-r40634 std

BrainSlayer wrote:
we just do it since we do not like any restrictions enforced by stupid cocaine snorting managers

If you use DSLReports please enable hi-res bufferbloat.


Sigh.. why do i exist anyway..
Malachi
DD-WRT Guru


Joined: 17 Jul 2012
Posts: 7162
Location: Columbus, Ohio

PostPosted: Sat Jun 30, 2018 0:41    Post subject: Reply with quote
Smaller pictures please.
_________________
I am far from a guru, I'm barely a novice.
d0ug
DD-WRT Guru


Joined: 31 Jul 2015
Posts: 754

PostPosted: Sat Jun 30, 2018 19:52    Post subject: Reply with quote
tatsuya46 wrote:
known issue, ddwrt cant handle setting a date/time manually, it depends on having wan. dont ask why.


If you disable the WAN port, DDWRT will fetch NTP over the LAN ports. I have two WRT1200AC routers here at the house that I just use as APs. I initially noticed this behavior about a year ago, when I set them up. They would not NTP update. I eventually disabled the WAN port on both of them since it wasn't needed in the setup I was using them and mysteriously the NTP started working. It appears the default config binds the NTP client to the WAN port interface. When that is disabled it binds to another interface.

This may also have something to do with the default routing config. Since I do have the WAN port enabled on my 3rd WRT1200AC that is doing the routing for my LAN. On this router I have it setup to pull time off an NTP server I have running on the LAN subnet and it has no issues pulling the time off that NTP server, however if you specified any other external IP it is probably going to try and access it over the WAN port.
mrjcd
DD-WRT Guru


Joined: 31 Jan 2015
Posts: 4638
Location: Texas

PostPosted: Sat Jun 30, 2018 21:25    Post subject: Reply with quote
I have 7 dd-wrt devices connected to my main network that are up 24/7.
Ranging from EA8500, WNDR3700v4, WNR2000v3, E2100L units + WRT54G & WAP54G units.
They all have WAN disabled & DHCP disabled but have main router IP as gateway.
NTP Client is enabled.
Time Zone is set correctly.
Server IP/Name is left blank (dd-wrt built-in works fine).
They all keep correct time and have for very long time, several years Smile
gil_happy
DD-WRT User


Joined: 24 Sep 2009
Posts: 105

PostPosted: Sun Jul 01, 2018 15:08    Post subject: Reply with quote
mrjcd wrote:
I have 7 dd-wrt devices connected to my main network that are up 24/7.
Ranging from EA8500, WNDR3700v4, WNR2000v3, E2100L units + WRT54G & WAP54G units.
They all have WAN disabled & DHCP disabled but have main router IP as gateway.
NTP Client is enabled.
Time Zone is set correctly.
Server IP/Name is left blank (dd-wrt built-in works fine).
They all keep correct time and have for very long time, several years Smile


Thank you... I will try on Tuesday and see if this works.
gil_happy
DD-WRT User


Joined: 24 Sep 2009
Posts: 105

PostPosted: Sun Jul 01, 2018 15:10    Post subject: Reply with quote
tatsuya46 wrote:
known issue, ddwrt cant handle setting a date/time manually, it depends on having wan. dont ask why.


Unfortunately I am not setting the date / time manually. This device appears to lose its NTP time / date after a short period of time (maybe a week or so).
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum