Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make NTP configurable #1241

Open
5xPa opened this issue Mar 7, 2023 · 13 comments
Open

make NTP configurable #1241

5xPa opened this issue Mar 7, 2023 · 13 comments
Labels
enhancement New feature or request

Comments

@5xPa
Copy link

5xPa commented Mar 7, 2023

I have setup a Firewall rule blocking my IOT devices from the internet.

I then have shelly mongoose devices regularly trying to poll time.google.com
Mar 7 13:50:46 oor: [FILTER][Block][LAN/RT/VPN->WAN, 26:32:41 ][@s:R=1:2, 192.168.0.181:4097
Mar 7 13:51:16 oor: Local User (MAC=40-F5-20-00-CD-7E): 192.168.0.181 DNS -> 208.67.222.222 inquire time.google.com
Mar 7 13:51:16 oor: [FILTER][Block][LAN/RT/VPN->WAN, 26:33:12 ][@s:R=1:2, 192.168.0.181:4097-
Mar 7 13:51:43 oor: Local User (MAC=40-F5-20-00-CD-7E): 192.168.0.181 DNS -> 208.67.222.222 inquire time.google.com.
I guess it must make the connection to the timeserver if not keep trying

In my router a Draytek. I can forward an external request to an internal address ie
forward time.google.com >>> 192.168.0.37 Synology NAS with a time sever running. The number of polls to time.google.com drops to about 1 per hour.

Mar 7 17:33:25 oor: Local User (MAC=40-F5-20-00-CD-7E): 192.168.0.181 DNS -> 208.67.222.222 inquire time.google.com

It would appear it still passes to time.google.com

Sorry for the longwinded explanation, would it be possible to have an option to manually set the time server?

@5xPa
Copy link
Author

5xPa commented Mar 9, 2023

Am I correct that calls are made to NTP servers time.google.com

@timoschilling
Copy link
Collaborator

Yes the Shelly uses time.google.com for time resolving

@5xPa
Copy link
Author

5xPa commented Mar 9, 2023

Thanks for the reply. Any chance of making it a manual choice in the setup?

@timoschilling timoschilling added the enhancement New feature or request label Mar 9, 2023
@5xPa
Copy link
Author

5xPa commented Mar 14, 2023

Timo another question regarding Time server.
I have been as mentioned trying to utilise Draytek LAN dns forwarding, to redirect time.google.com to my local time server.
I found some info on a "type 65 Dns request" if I understand this correctly this forces DNS requests to the time sever in the code.
My question the mongoose firmware issuing a DNS request that forces the request to bypass my LAN and router settings?

Thanks for all the great work and answer my probably fairly basic questions.

@timoschilling
Copy link
Collaborator

I don't know have a deep knowledge about that DNS behaviour, that's functionality of the underlaying Mongoose OS.

In the next version the setting of a DNS server will be possible. And in the future it will be possible to set the ntp server.

@5xPa
Copy link
Author

5xPa commented Mar 14, 2023

Once again thanks for the reply. I was trying to establish if it's Mongoose which was overriding the Lan/Dns forwarding of the router.
I look forward to the next release, I have 21 device a combination of shelly 1, 2.5 and Uni the are very reliable.

@timoschilling timoschilling changed the title NTP regular calls to time.google.com I block external calls make NTP configurable Mar 17, 2023
@nliviu
Copy link

nliviu commented Sep 8, 2023

You can change the ntp server:

curl http://shelly_ip/rpc/Config.Set -d '{"config":{"sntp":{"server":"ntp_server"}},"save":true,"reboot":true}'

@5xPa
Copy link
Author

5xPa commented Sep 8, 2023

nliviu thanks for the info. Unfortunately I am not familiar with "curl" I I have downloaded and installed. Can you confirm this exactly the command I would issue for a shelly device ip 192.168.0.176 setting the NTP server to 192.168.0.37

curl http://192.168.0.176/rpc/Config.Set -d '{"config":{"sntp":{"server":"192.168.0.37"}},"save":true,"reboot":true}'

@nliviu
Copy link

nliviu commented Sep 8, 2023

It looks ok.

@5xPa
Copy link
Author

5xPa commented Sep 8, 2023

Hi nilivui entered exactly as following
curl http://192.168.0.176/rpc/Config.Set -d '{"config":{"sntp":{"server":"192.168.0.37"}},"save":true,"reboot":true}'

received error message {"code":400,"message":"value is required"}

Googled the error message
The 400 Bad request status code indicates that the server was unable to process the request due to invalid information sent by the client. In other words, the client request needs modification

No idea how to proceed, be grateful for your assistance

@nliviu
Copy link

nliviu commented Sep 8, 2023

I suppose you are on Windows:

"{\"config\":{\"sntp\":{\"server\":\"time.google.com\"}},\"save\":true,\"reboot\":true}"

@5xPa
Copy link
Author

5xPa commented Sep 8, 2023 via email

@JPM-git
Copy link

JPM-git commented Mar 26, 2024

I was just searching for something to make use of dns server after 1.5 update but came across this thread with almost 6 months and no replay.

the error is in the command

I did try curl http://192.168.0.176/rpc/Config.Set -d
"{"config":{"sntp":{"server":"192.168.0.37"}},"save":true,"reboot":true}"

you missed a \ after the ip address, " is a special character so you need to "escape" it

if you see close you have it on the fqdn command but when you replace with the ip you wrongly deleted it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants