DHCP: Timezone - themactep/thingino-firmware GitHub Wiki

Setting Timezone via DHCP

Introduction

Dynamic Host Configuration Protocol (DHCP) can deliver timezone information to clients, improving time synchronization without manual setup. This uses vendor-specific options defined in RFC 4833.

DHCP Options

  • Option 100 (PCode): POSIX timezone string (e.g., "EST5EDT").
  • Option 101 (TCode): IANA TZ database name (e.g., "America/New_York").

Clients request these via Parameter-Request List (option 55). Servers include them in DHCP Offers and ACKs if requested.

Server Configuration

Configure on DHCP servers like MikroTik, pfSense, or OpenWRT:

  • Define options (e.g., code 100 value "EST5EDT", code 101 value "America/New_York").
  • Assign to network/subnet.
  • Example (MikroTik):
    /ip dhcp-server option add code=100 name=pcode value="'EST5EDT'"
    /ip dhcp-server option add code=101 name=tcode value="'America/New_York'"
    /ip dhcp-server network set 0 dhcp-option="pcode,tcode"
    

Renew client leases to apply.

Client Support

Embedded Linux (udhcpc) requests with -O 100 -O 101. Windows and Raspberry Pi support via APIs. Verify with tcpdump or Wireshark.

Configuration Examples

Using dnsmasq

# Option 100 - POSIX TZ Code
dhcp-option=100,"NZST-12NZDT,M9.5.0/2,M4.1.0/3"
# Option 101 - TCode
dhcp-option=101,"Pacific/Auckland"

Using Junos Apply groups

set groups default-dhcp-attributes routing-instances <*> access address-assignment pool <*> family inet dhcp-attributes option 100 string NZST-12NZDT,M9.5.0/2,M4.1.0/3
set groups default-dhcp-attributes routing-instances <*> access address-assignment pool <*> family inet dhcp-attributes option 101 string Pacific/Auckland

Using ISC DHCP server

option PCode code 100 = text;
option TCode code 101 = text;
option PCode "NZST-12NZDT,M9.5.0/2,M4.1.0/3";
option TCode "Pacific/Auckland";

Using RouterOS DHCP server

/ip dhcp-server option add code=100 name=pcode value="'EST5EDT'"
/ip dhcp-server option add code=101 name=tcode value="'America/New_York'"
/ip dhcp-server network set 0 dhcp-option="pcode,tcode"