Skip to content

Commit 73be35c

Browse files
masc2008acassis
authored andcommitted
Documentation/ntpc: document DHCP NTP server support
Document that ntpc can use NTP servers learned from DHCP option 42 when DHCP client support is enabled. Signed-off-by: Jerry Ma <shichunma@bestechnic.com>
1 parent 8653569 commit 73be35c

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

  • Documentation/applications/system/ntpc

Documentation/applications/system/ntpc/index.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ The ntpc example:
1515

1616
- Connects to NTP servers (default: pool.ntp.org)
1717

18+
- Supports NTP server configuration learned from DHCP option 42
19+
1820
- Starts the NTP client in the background for continuous synchronization
1921

2022
- Provides commands to check status and stop the NTP client
@@ -37,13 +39,18 @@ This example requires the following NuttX configuration options:
3739
- CONFIG_SYSTEM_NTPC: Enable this example
3840

3941
Additional configuration options:
42+
4043
- CONFIG_NETUTILS_NTPCLIENT_SERVER: NTP server hostname (default: "pool.ntp.org")
44+
- CONFIG_NETUTILS_DHCPC: Enable DHCP client support when NTP servers should be
45+
learned dynamically from DHCP option 42
4146

4247
Usage
4348
-----
4449

4550
1. Configure your NuttX build with networking support
4651
2. Ensure network connectivity is established (e.g., via NSH network commands)
52+
If DHCP provides NTP servers through option 42, ``ntpc`` can use that
53+
server list automatically.
4754
3. Build and flash the image to your target board
4855
4. Run the commands:
4956
- ``ntpcstart``, ``ntpcstop``, ``ntpcstatus``
@@ -95,6 +102,27 @@ give the proper time and date.
95102
nsh> date
96103
Fri, Sep 05 18:49:37 2025
97104

105+
DHCP-provided NTP servers
106+
-------------------------
107+
108+
When ``CONFIG_NETUTILS_DHCPC`` is enabled, the DHCP client can pass NTP
109+
server IPv4 addresses learned from DHCP option 42 to ``ntpc``.
110+
111+
This allows ``ntpc`` to run without a fixed server hostname in the
112+
configuration and to follow NTP server updates delivered by DHCP.
113+
114+
One way to test DHCP-delivered NTP servers is with ``dnsmasq``:
115+
116+
::
117+
118+
dnsmasq --no-daemon --log-dhcp --log-queries \
119+
--interface=tap0 --bind-interfaces \
120+
--dhcp-authoritative \
121+
--dhcp-range=192.168.50.20,192.168.50.50,255.255.255.0 \
122+
--dhcp-option=option:router,192.168.50.1 \
123+
--dhcp-option=option:dns-server,1.1.1.1 \
124+
--dhcp-option=option:ntp-server,162.159.200.123
125+
98126
Notes
99127
-----
100128

0 commit comments

Comments
 (0)