1# DHCPv4 implementation for Zephyr 2 3# Copyright (c) 2016 Intel Corporation. 4# Copyright (c) 2024 Nordic Semiconductor ASA 5# 6# SPDX-License-Identifier: Apache-2.0 7 8config NET_DHCPV4 9 bool "DHCPv4 client" 10 select NET_MGMT 11 select NET_MGMT_EVENT 12 select NET_MGMT_EVENT_INFO if NET_IPV4_ACD 13 depends on NET_IPV4 && NET_UDP 14 15if NET_DHCPV4 16 17module = NET_DHCPV4 18module-dep = NET_LOG 19module-str = Log level for DHCPv4 client 20module-help = Enable debug diagnostic from DHCPV4 client. 21source "subsys/net/Kconfig.template.log_config.net" 22 23config NET_DHCPV4_INITIAL_DELAY_MAX 24 int "Maximum time out for initial discover request" 25 default 10 26 range 2 10 27 help 28 As per RFC2131 4.1.1, we wait a random period between 29 1 and 10 seconds before sending the initial discover. 30 31config NET_DHCPV4_OPTION_CALLBACKS 32 bool "Option callbacks" 33 help 34 If set, custom callbacks for arbitrary DHCP options 35 can be added. These can be used to support otherwise 36 DHCP options not used by the rest of the system. 37 38config NET_DHCPV4_MAX_REQUESTED_OPTIONS 39 int "Maximum number of requested options" 40 depends on NET_DHCPV4_OPTION_CALLBACKS 41 default 10 42 range 3 $(UINT8_MAX) 43 help 44 Maximum number of requested options that can be added to the 45 DHCPv4 request message. The options are added using the 46 net_dhcpv4_add_option_callback() API. 47 48config NET_DHCPV4_OPTION_CALLBACKS_VENDOR_SPECIFIC 49 bool "Encapsulated vendor specific option callbacks" 50 select NET_DHCPV4_OPTION_CALLBACKS 51 help 52 If set, custom callbacks for encapsulated vendor-specific 53 information in DHCP option 43 can be added. 54 55config NET_DHCPV4_ACCEPT_UNICAST 56 bool "Accept unicast DHCPv4 traffic" 57 default y 58 help 59 If set, the network stack will accept unicast DHCPv4 responses from 60 servers, before the assigned address is configured on the interface. 61 62config NET_DHCPV4_VENDOR_CLASS_IDENTIFIER 63 bool "Send vendor class identifier in DHCPv4 request" 64 help 65 If set, the network stack will include the specified string in the 66 DHCPv4 vendor class identifier option in the DHCPv4 request. 67 68config NET_DHCPV4_VENDOR_CLASS_IDENTIFIER_STRING 69 string "Vendor class identifier" 70 depends on NET_DHCPV4_VENDOR_CLASS_IDENTIFIER 71 default "" 72 help 73 The string to include in the DHCPv4 vendor class identifier option 74 in the DHCPv4 request. 75 76config NET_DHCPV4_OPTION_NTP_SERVER 77 bool "Use NTP server from DHCPv4 option and save it in the net_if" 78 default y 79 depends on SNTP 80 help 81 If this option is set, then the NTP server can be set from the 82 DHCPv4 option. 83 84config NET_DHCPV4_OPTION_DNS_ADDRESS 85 bool "Use DNS server from DHCPv4 option and save it in the DNS resolver default context" 86 default y 87 depends on DNS_RESOLVER 88 help 89 If this option is set, then the DNS server can be set from the 90 DHCPv4 option. 91 92config NET_DHCPV4_OPTION_PRINT_IGNORED 93 bool "Print information about ignored options" 94 help 95 If this option is set, then we print information about options that we 96 received and ignored. If this is not set, then we print these as unknown 97 options. 98 99config NET_DHCPV4_DNS_SERVER_VIA_INTERFACE 100 bool "Make DNS servers specific to the network interface" 101 depends on NET_DHCPV4_OPTION_DNS_ADDRESS 102 default y 103 help 104 If this is set, then if the system has multiple network interfaces 105 and each has DHCP enabled, then assign DNS servers received from that 106 network interface, to that specific interface. 107 If this option is not set, then any interface can be used for all 108 the configured DNS server addresses when doing DNS queries. 109 Example: We receive DNS server 192.0.2.53 DHCPv4 option from Wi-Fi 110 interface and DNS server 198.51.100.53 from Ethernet interface. 111 When this option is set, the DNS resolver will use DNS server 112 192.0.2.53 when sending DNS query to the Wi-Fi interface and DNS 113 server 198.51.100.53 when sending DNS query to the Ethernet 114 interface. 115 116config NET_DHCPV4_INIT_REBOOT 117 bool "Support INIT-REBOOT" 118 default y 119 help 120 Initialization with a known network address, if the DHCPv4 client has 121 been assigned an address before, it begins in INIT-REBOOT state and 122 sends a DHCPREQUEST message. 123 124endif # NET_DHCPV4 125 126config NET_DHCPV4_SERVER 127 bool "DHCPv4 server" 128 depends on NET_IPV4 && NET_UDP 129 select NET_SOCKETS 130 select NET_SOCKETS_SERVICE 131 132if NET_DHCPV4_SERVER 133 134module = NET_DHCPV4_SERVER 135module-dep = NET_LOG 136module-str = Log level for DHCPv4 server 137module-help = Enables DHCPv4 server output debug messages 138source "subsys/net/Kconfig.template.log_config.net" 139 140config NET_DHCPV4_SERVER_INSTANCES 141 int "Maximum number of DHCPv4 server instances" 142 default 1 143 help 144 Maximum number of DHCPv4 server instances supported by the system. 145 Each network interface that wants to act as a DHCPv4 server requires 146 a separate instance. 147 148config NET_DHCPV4_SERVER_ADDR_COUNT 149 int "Number of IPv4 addresses that can be assigned by the server" 150 default 4 151 help 152 Maximum number of IPv4 addresses that can be assigned by the DHCPv4 153 server instance. The base IPv4 address in the address pool is provided 154 at runtime, during server initialization. Consecutive addresses in the 155 pool have the lowest address octet incremented. 156 157config NET_DHCPV4_SERVER_ADDR_LEASE_TIME 158 int "Lease time for IPv4 addresses assigned by the server (seconds)" 159 range 0 $(UINT32_MAX) 160 default 86400 161 help 162 Lease time in seconds for IPv4 addresses assigned by the server. 163 The lease time determines when the IPv4 address lease expires if the 164 client does not renew it. 165 166config NET_DHCPV4_SERVER_ADDR_DECLINE_TIME 167 int "The time IPv4 addresses remains blocked after conflict detection (seconds)" 168 range 0 $(UINT32_MAX) 169 default 86400 170 help 171 In case IPv4 address becomes blocked (either because of receiving 172 Decline message or due to ICMP probe detecting conflict), the address 173 can no longer be assigned. This timeout specifies how long the address 174 remains in the Declined state. 175 Note, that the server may try to reuse the oldest declined address in 176 case it runs out of free addresses to assign. 177 178config NET_DHCPV4_SERVER_ICMP_PROBE_TIMEOUT 179 int "Timeout for ICMP probes sent by the server (milliseconds)" 180 range 0 60000 181 default 1000 182 help 183 DHCPv4 server will probe the offered IP address (send ICMP echo 184 request) and wait for the time specific by this config before offering 185 the address. If set to 0, ICMP probing will be disabled. 186 187config NET_DHCPV4_SERVER_NAK_UNRECOGNIZED_REQUESTS 188 bool "Reply with NAK for DHCP Requests from clients we do not recognize" 189 default y 190 help 191 Zephyr's DHCPv4 server does not implement persistent storage of address 192 leases. As a result, all leases are lost on reboot, which can cause 193 delays with clients starting in INIT-REBOOT state and thus sending 194 (potentially several) Requests before attempting full Discover-Request 195 procedure. Enabling this config will violate the RFC in this regard, as 196 instead of staying silent for unrecognized Request messages, the server 197 will send a NAK, informing the client it should proceed with a full 198 procedure. 199 200config NET_DHCPV4_SERVER_OPTION_DNS_ADDRESS 201 string "DNS Server address" 202 default DNS_SERVER1 if DNS_SERVER_IP_ADDRESSES 203 default "" 204 help 205 This configuration option specifies the DNS server address that the DHCPv4 206 server should provide to clients when they request an IP address. The 207 DHCPv4 server adds this DNS server address in the DHCP offer and 208 acknowledgment messages sent to the clients, allowing them to use the 209 specified DNS server for name resolution. 210 211config NET_DHCPV4_SERVER_OPTION_ROUTER 212 bool "Set the router option in the DHCP server response" 213 default y 214 help 215 If enabled, set the DHCP router option pointing to the interface own 216 gateway address in responses from the DHCP server. This can be 217 disabled so that the client does not try to forward traffic to our 218 device. 219 220endif # NET_DHCPV4_SERVER 221