1

In a comment on this question Robert asked:

Have you tried to provide an NTP server in your local network and announce it via DHCP?

How can I do that, please? I have several development devices whose only connectivity is ADB over USB to a Linux development host. That's part of a corporate network with an NTP server. The devices' date and time drifts, and has to be reset occasionally. Being able to tell them about an NTP server would be splendid, if they can access it through the ADB/USB connection.

I have root on the devices, and can this change their date & time from the ADB shell. If I couldn't do that, I'd use the GUI. They're running a pretty vanilla Android 12.

0

1 Answer 1

0

The DHCP server of a network can be configured to not only provide a client IP address and DNS/WINS server IPs, but also the IP of a NTP server. Some (home) routers that provide NTP for the network already announce their own IP via DHCP as NTP server. However I am not sure how common it is for Android devices processing this DHCP field and using it's announced NTP server.

I think most Google Android devices by default will still use ntp://time.android.com (or the manufacturer specific NTP server).

Alternatively you can manually specify the NTP server via ADB:

adb shell settings put global ntp_server <new-ntp-server>

See How can I set a server address to automatically sync my device time?

7
  • I may have misunderstood you. The development devices I'm using don't have any form of Internet connectivity, so they can't see ntp://time.android.com, and don't have any communication with a DHCP server at present. I thought you were commenting about a way to tell a device about the IP address of a DHCP server. Commented Jun 20 at 15:47
  • @JohnDallman DHCP servers are found by all devices automatically as DHCP traffic uses broadcast communication. Do you mean "any form of Internet" or "any form of network"? There is a big difference... Anyway all Linux system have network - at least localhost. So if there is no other networking you could still try to run an ntp server on localhost (with a different port as everything below 1024 requires root). I just don't know if Android allows to use a time server on port different to 123.
    – Robert
    Commented Jun 20 at 17:20
  • No network at all, except anything that comes through the default settings of ADB over USB, which is nothing AFAIK. The Linux host is part of the corporate network, on a company site. Commented Jun 20 at 17:25
  • @JohnDallman adb allows TCP and UDP port forwarding, unfortunately as you don't have root only for ports larger than 1024 (for the local port on Android side).
    – Robert
    Commented Jun 20 at 17:29
  • I have root, but a very limited understanding of TCP and UDP. Commented Jun 20 at 18:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .