Timezone Options for DHCP: RFC 4833

... now I wonder where does it take its parameters from.

I use this on my home network too.

All servers and network stuff gets utc while all clients get explicit Berlin time...

You have to configure that the client requests and honors the setting :confused:

Do they get TZ correction from DHCP though?

At least the Linux boxes where I have configured that the option is requested. And I think but not entirely sure the windows boxes from work do honor it.

odhcpd recently added more support for the timezones, but it reads them from the uci system config.

Thank you! I figured that out when tried to enable "enable_tz" option on current stable build (24.10.4) and it failed because the option is not yet supported.

I use dnsmasq-full and not odhcpd. Forgot to mention that.

And on.

I was not entirely sure about that memory of mine but the Google ki agrees with me

https://www.google.com/search?q=does+Android+use+rfc4833

Upon further investigation I've discovered that systemd can get TZ information via DHCP but it is disabled by default ( UseTimezone option). NTP server information on the other hand is enabled (UseNTP option).

Just to summarize:

  1. This recommendation by @poddmo can be indeed useful for most Linux users after some tweaking :slight_smile:
  2. DHCPv6 TZ options will be available in next stable release.

And commands to make that work on server side will look something like this:

uci add_list dhcp.lan.dhcp_option='option:ntp-server,192.168.1.1'
uci add_list dhcp.lan.dhcp_option='option:posix-timezone,"AEST-10AEDT,M10.1.0/02:00,M4.1.0/03:00"'
uci add_list dhcp.lan.dhcp_option='option:tzdb-timezone,"Australia/Sydney"'
uci commit

P.S. someone has to try if it actually works with real world clients...

This is gold - well done.

I fired up a minimal Ubuntu 24.04 server VM in virtualbox, bridged to my LAN so it gets DHCP from my OpenWRT router that is configured for DHCP timezone options.
Then I set the timezone to Etc/UTC using dpkg-reconfigure tzdata and timedatectl set-timezone Etc/UTC (maybe at this point you can guess where this is going...)
I checked the config by cat /etc/timezone, timedatectl, and plain old date - all showing the UTC timezone.

I then deleted everything in the /etc/netplan directory and created a file: /etc/systemd/network/enp0s3.network with the following config:

[Match]
Name=enp0s3

[Network]
DHCP=yes

[DHCPv4]
UseNTP=true
UseTimezone=true

Then issued systemctl daemon-reload and then systemctl restart systemd-networkd.service

The results:

  • dhcpdump shows that the dhcp client is now requesting DHCP option 101 (TCode - ie database name eg Australia/Sydney)
  • timedatectl shows the time zone now set to Australia/Sydney
  • date shows the time zone now set to Australia/Sydney
  • cat /etc/timezone still shows the old UTC timezone

So, the timezone is requested by DHCP option and is used to update the system clock and systemd, but it doesn't touch the filesystem. There could be somewhere to hook a script to tidy that up too.

Did you use human readable notation option:ntp-server or numerical 42? I wasn't sure about that, never tried it. I found it dnsmasq sources.

I'm using numerical in my dnsmasq config on OpenWrt

	list dhcp_option_force '101,"Australia/Sydney"'
	list dhcp_option_force '100,"AEST-10AEDT,M10.1.0/02:00,M4.1.0/03:00"'
	list dhcp_option '42,10.0.0.1'

I haven't tried it but dnsmasq might accept it either way. It knows both forms:

root@openwrt:/etc/config# dnsmasq --help dhcp | grep -E 'ntp|timezone'
 42 ntp-server
 71 nntp-server
100 posix-timezone
101 tzdb-timezone

Great! Now is the time to figure out whether Windows PCs support it or not (I don't have access to it)... and mobiles. But those I bet will prioritize cell tower beacons or 802.11v TZ option (if anything supports it).

They do not.

(I was also aware of time and systemd for Linux, but requires configuration on clients, as noted.)

That part. But would it matter if you always intended to provide timezone via DHCP?

(I guess a laptop, maybe.)

Android, no:

At least we can intercept UDP port 123 requests :laughing:

Google Ai in the top says 'yes' (:person_facepalming:) while tcpdump capture says 'nope'.

... but what about OpenWrt setting its timezone via DHCP option 100 or 101?

I've been thinking about this a bit.. I think they should request and set timezone details. I have OpenWrt on the internet gateway and then also on two downstream wireless access points. They were only DHCP for a few minutes until I gave them their static IP details but they should respect the local time server+timezone if available.
I do also wonder about security and if a rogue dhcp server could inject bad NTP and timezone config.. I guess that's another benefit of static configuration.

Oh boy. Yes 10 sec of more research suggests that's and android does not indeed use it.

Thanks for confirmation.

There is an old Soviet anecdote about a guy who wanted to become a writer but couldn't read, - "No problem, I'm a writer, not a reader". Same about OpenWrt, - it can advertise, but can't use it.