Skip to content

Commit c20302d

Browse files
pi-anldpgeorge
authored andcommitted
shared/netutils/dhcpserver: Set default DNS to the server address.
This sets the DHCP server's own IP address as the default DNS server when no explicit DNS is configured, providing a more complete network configuration for DHCP clients. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
1 parent 367178f commit c20302d

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

shared/netutils/dhcpserver.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@
6565
#define PORT_DHCP_SERVER (67)
6666
#define PORT_DHCP_CLIENT (68)
6767

68-
#define DEFAULT_DNS MAKE_IP4(192, 168, 4, 1)
6968
#define DEFAULT_LEASE_TIME_S (24 * 60 * 60) // in seconds
7069

7170
#define MAC_LEN (6)
72-
#define MAKE_IP4(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))
7371

7472
typedef struct {
7573
uint8_t op; // message opcode
@@ -283,7 +281,7 @@ static void dhcp_server_process(void *arg, struct udp_pcb *upcb, struct pbuf *p,
283281
opt_write_n(&opt, DHCP_OPT_SERVER_ID, 4, &ip_2_ip4(&d->ip)->addr);
284282
opt_write_n(&opt, DHCP_OPT_SUBNET_MASK, 4, &ip_2_ip4(&d->nm)->addr);
285283
opt_write_n(&opt, DHCP_OPT_ROUTER, 4, &ip_2_ip4(&d->ip)->addr); // aka gateway; can have multiple addresses
286-
opt_write_u32(&opt, DHCP_OPT_DNS, DEFAULT_DNS); // can have multiple addresses
284+
opt_write_n(&opt, DHCP_OPT_DNS, 4, &ip_2_ip4(&d->ip)->addr);
287285
opt_write_u32(&opt, DHCP_OPT_IP_LEASE_TIME, DEFAULT_LEASE_TIME_S);
288286
*opt++ = DHCP_OPT_END;
289287
struct netif *netif = ip_current_input_netif();

0 commit comments

Comments
 (0)