net: dhcpv6: Honor network interface for DNS servers
Bind the network interface to the network interface we have received the DNS servers from. This is now the default. The previous behavior can be restored by disabling the CONFIG_NET_DHCPV6_DNS_SERVER_VIA_INTERFACE option. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
1224c5a43a
commit
248cb3d251
2 changed files with 36 additions and 1 deletions
|
@ -31,6 +31,23 @@ config NET_DHCPV6_OPTION_DNS_ADDRESS
|
|||
option from the server, and if available, use obtained information
|
||||
to configure DNS resolver.
|
||||
|
||||
config NET_DHCPV6_DNS_SERVER_VIA_INTERFACE
|
||||
bool "Make DNS servers specific to the network interface"
|
||||
depends on NET_DHCPV6_OPTION_DNS_ADDRESS
|
||||
default y
|
||||
help
|
||||
If this is set, then if the system has multiple network interfaces
|
||||
and each has DHCP enabled, then assign DNS servers received from that
|
||||
network interface, to that specific interface.
|
||||
If this option is not set, then any interface can be used for all
|
||||
the configured DNS server addresses when doing DNS queries.
|
||||
Example: We receive DNS server 2001:db8::1:53 DHCPv6 option from Wi-Fi
|
||||
interface and DNS server 2001:db8::2:53 from Ethernet interface.
|
||||
When this option is set, the DNS resolver will use DNS server
|
||||
2001:db8::1:53 when sending DNS query to the Wi-Fi interface and DNS
|
||||
server 2001:db8::2:53 when sending DNS query to the Ethernet
|
||||
interface.
|
||||
|
||||
if NET_DHCPV6
|
||||
module = NET_DHCPV6
|
||||
module-dep = NET_LOG
|
||||
|
|
|
@ -1412,7 +1412,25 @@ static int dhcpv6_handle_dns_server_option(struct net_pkt *pkt)
|
|||
}
|
||||
|
||||
ctx = dns_resolve_get_default();
|
||||
status = dns_resolve_reconfigure(ctx, NULL, dns_servers);
|
||||
|
||||
if (IS_ENABLED(CONFIG_NET_DHCPV6_DNS_SERVER_VIA_INTERFACE)) {
|
||||
/* If we are using the interface to resolve DNS servers,
|
||||
* we need to save the interface index.
|
||||
*/
|
||||
int ifindex = net_if_get_by_iface(net_pkt_iface(pkt));
|
||||
int interfaces[MAX_DNS_SERVERS];
|
||||
|
||||
for (uint8_t i = 0; i < server_count; i++) {
|
||||
interfaces[i] = ifindex;
|
||||
}
|
||||
|
||||
status = dns_resolve_reconfigure_with_interfaces(ctx, NULL,
|
||||
dns_servers,
|
||||
interfaces);
|
||||
} else {
|
||||
status = dns_resolve_reconfigure(ctx, NULL, dns_servers);
|
||||
}
|
||||
|
||||
if (status < 0) {
|
||||
NET_DBG("Failed to reconfigure DNS resolver from DHCPv6 "
|
||||
"option: %d", status);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue