Wi-Fi: fixed IPv4 settings (address, gateway, DNS) and NTP servers #7

Closed
opened 2026-10-05 09:44:49 +00:00 by twisla · 2 comments
Owner

Idea

In Settings, let each network use either DHCP or a fixed IPv4 configuration: address, netmask, gateway and DNS servers. Also make the NTP servers configurable. Both come with public defaults, so they work out of the box.

Why

Not every network has a DHCP server: a lab bench, a direct link to a router, a phone hotspot with DHCP turned off, or a network where addresses are handed out by hand. This is basic system configuration. Today the device simply can't join such a network.

What's known

  • Today. Every Saved Network uses DHCP, the NTP server is hard-coded to pool.ntp.org (src/services/wifi_service.cpp:92), and DNS always comes from DHCP.
  • Where it's stored.
    • Saved Networks live in lib/wifi/src/saved_networks.h, and the IP configuration belongs to a network: an address that's right on one network is wrong on another.
    • So DHCP or fixed, plus the fixed settings, would be stored per Saved Network.
    • DNS and NTP servers make sense as global settings with defaults, maybe with a per-network override.
  • How it's applied.
    • Arduino's WiFi.config(ip, gateway, subnet, dns1, dns2) is called before connecting. With DHCP, DNS comes from the DHCP server unless overridden.
    • The address must be checked on entry: a valid IPv4 address, the gateway inside the subnet, and the netmask contiguous. All of that is pure logic that can be host-tested in lib/wifi.
  • DNS defaults. Public resolvers, for example Quad9 9.9.9.9 with Cloudflare 1.1.1.1 as the second. lwIP holds up to 3 DNS servers.
  • NTP.
    • Default: pool.ntp.org, as today.
    • Up to 3 servers. lwIP's SNTP allows only 1 by default, so CONFIG_LWIP_SNTP_MAX_SERVERS has to be raised in custom_sdkconfig, next to the TLS buffer settings (ADR 0006).
    • DHCP can also hand out NTP servers (DHCP option 42), and lwIP can use them: esp_sntp_servermode_dhcp.
    • NTP still ranks below GNSS in the clock trust order. That doesn't change.
  • Entering addresses. IPv4 addresses are fiddly to type on this keyboard. An entry field that only takes digits and dots, or four number fields per address, would help.

Questions for the design round

  1. Per network or global?
    • Fixed IP per Saved Network: agreed?
    • DNS and NTP global with per-network overrides, or global only?
  2. Should "DHCP with my own DNS" be an option, separate from fully fixed?
  3. Which public defaults for DNS and NTP? Should they be shown as defaults (greyed) until changed?
  4. Should NTP servers from DHCP be used when offered, before or after the configured ones?
  5. Where should it go: inside each Saved Network's page in Settings > Wi-Fi, plus a "Network" section for DNS and NTP?
  6. What should the status page show: the current address, gateway and DNS, and whether they came from DHCP or the fixed settings?
  7. IPv6 is out of scope for now. Agreed?

Related

lib/wifi/src/saved_networks.h, src/services/wifi_service.cpp (startNtp), src/apps/wifi_settings_page.cpp, ADR 0006 (custom_sdkconfig).

## Idea In Settings, let each network use either DHCP or a fixed IPv4 configuration: address, netmask, gateway and DNS servers. Also make the NTP servers configurable. Both come with public defaults, so they work out of the box. ## Why Not every network has a DHCP server: a lab bench, a direct link to a router, a phone hotspot with DHCP turned off, or a network where addresses are handed out by hand. This is basic system configuration. Today the device simply can't join such a network. ## What's known - **Today.** Every Saved Network uses DHCP, the NTP server is hard-coded to `pool.ntp.org` (`src/services/wifi_service.cpp:92`), and DNS always comes from DHCP. - **Where it's stored.** - Saved Networks live in `lib/wifi/src/saved_networks.h`, and the IP configuration belongs to a network: an address that's right on one network is wrong on another. - So DHCP or fixed, plus the fixed settings, would be stored per Saved Network. - DNS and NTP servers make sense as global settings with defaults, maybe with a per-network override. - **How it's applied.** - Arduino's `WiFi.config(ip, gateway, subnet, dns1, dns2)` is called before connecting. With DHCP, DNS comes from the DHCP server unless overridden. - The address must be checked on entry: a valid IPv4 address, the gateway inside the subnet, and the netmask contiguous. All of that is pure logic that can be host-tested in `lib/wifi`. - **DNS defaults.** Public resolvers, for example Quad9 `9.9.9.9` with Cloudflare `1.1.1.1` as the second. lwIP holds up to 3 DNS servers. - **NTP.** - Default: `pool.ntp.org`, as today. - Up to 3 servers. lwIP's SNTP allows only 1 by default, so `CONFIG_LWIP_SNTP_MAX_SERVERS` has to be raised in `custom_sdkconfig`, next to the TLS buffer settings (ADR 0006). - DHCP can also hand out NTP servers (DHCP option 42), and lwIP can use them: `esp_sntp_servermode_dhcp`. - NTP still ranks below GNSS in the clock trust order. That doesn't change. - **Entering addresses.** IPv4 addresses are fiddly to type on this keyboard. An entry field that only takes digits and dots, or four number fields per address, would help. ## Questions for the design round 1. Per network or global? - Fixed IP per Saved Network: agreed? - DNS and NTP global with per-network overrides, or global only? 2. Should "DHCP with my own DNS" be an option, separate from fully fixed? 3. Which public defaults for DNS and NTP? Should they be shown as defaults (greyed) until changed? 4. Should NTP servers from DHCP be used when offered, before or after the configured ones? 5. Where should it go: inside each Saved Network's page in Settings > Wi-Fi, plus a "Network" section for DNS and NTP? 6. What should the status page show: the current address, gateway and DNS, and whether they came from DHCP or the fixed settings? 7. IPv6 is out of scope for now. Agreed? ## Related `lib/wifi/src/saved_networks.h`, `src/services/wifi_service.cpp` (`startNtp`), `src/apps/wifi_settings_page.cpp`, ADR 0006 (`custom_sdkconfig`).
twisla added the
kind
feature
area/uiarea/wifi
status
needs-design
priority
high
labels 2026-10-05 09:44:49 +00:00
twisla added this to the S1 System basics milestone 2026-10-05 20:14:06 +00:00
Author
Owner

Built on the s1 branch (bdd027c, 3e27973, and the Settings screens after them), following a design round (docs/milestones/S1.md, Q105 to Q116). Checked on the device, on knbg-guests (10.39.39.0/24, gateway 10.39.39.1).

What it does

  • Each Saved Network is Automatic (DHCP) or Fixed: an address, a prefix length and an optional gateway. Set on the network's own page in Settings > Wi-Fi, or with wifi ip.
  • DNS: two servers in Settings (9.9.9.9, 1.1.1.1), used on Fixed networks, or everywhere with "Always use my DNS".
  • NTP: two servers in Settings (pool.ntp.org, time.cloudflare.com), after any that DHCP offers.
  • Connection details: address, mask, gateway, DNS and NTP in use, and where each came from.
  • IPv4 only.

Corrections to the text above

  • The SDK didn't need rebuilding: it already allows 3 NTP servers and takes them from DHCP.
  • DNS and NTP are global, with no per-network override (Q108, Q116).

Tested: Fixed .12 and .13 reach the internet; a wrong gateway on a trial reverted by itself; back to DHCP; "Always use my DNS" on and off; both NTP servers answer; refusals on the console and in Settings.

Not tested: NTP servers offered by DHCP (this network offers none), and a Fixed network with no gateway.

To close when s1 is merged.

Built on the `s1` branch (`bdd027c`, `3e27973`, and the Settings screens after them), following a design round (`docs/milestones/S1.md`, Q105 to Q116). Checked on the device, on `knbg-guests` (10.39.39.0/24, gateway 10.39.39.1). **What it does** - Each Saved Network is *Automatic* (DHCP) or *Fixed*: an address, a prefix length and an optional gateway. Set on the network's own page in Settings > Wi-Fi, or with `wifi ip`. - DNS: two servers in Settings (9.9.9.9, 1.1.1.1), used on Fixed networks, or everywhere with "Always use my DNS". - NTP: two servers in Settings (pool.ntp.org, time.cloudflare.com), after any that DHCP offers. - Connection details: address, mask, gateway, DNS and NTP in use, and where each came from. - IPv4 only. **Corrections to the text above** - The SDK didn't need rebuilding: it already allows 3 NTP servers and takes them from DHCP. - DNS and NTP are global, with no per-network override (Q108, Q116). **Tested**: Fixed .12 and .13 reach the internet; a wrong gateway on a trial reverted by itself; back to DHCP; "Always use my DNS" on and off; both NTP servers answer; refusals on the console and in Settings. **Not tested**: NTP servers offered by DHCP (this network offers none), and a Fixed network with no gateway. To close when `s1` is merged.
twisla added
status
ready
and removed
status
needs-design
labels 2026-10-05 22:04:55 +00:00
Author
Owner

Shipped in v0.7.0 (s1 merged into main).

Shipped in v0.7.0 (`s1` merged into `main`).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: twisla/roro9stack#7