From 73f50a76aac20a9c2fda67c5eba25661e2ebb119 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Wed, 2 Nov 2022 23:52:38 +0100 Subject: conf: Split the notions of read DNS addresses and offered ones With --dns-forward, if the host has a loopback address configured as DNS server, we should actually use it to forward queries, but, if --no-map-gw is passed, we shouldn't offer the same address via DHCP, NDP and DHCPv6, because it's not going to be reachable. Problematic configuration: * systemd-resolved configuring the usual 127.0.0.53 on the host: we read that from /etc/resolv.conf * --dns-forward specified with an unrelated address, for example 198.51.100.1 We still want to forward queries to 127.0.0.53, if we receive one directed to 198.51.100.1, so we can't drop 127.0.0.53 from our list: we want to use it for forwarding. At the same time, we shouldn't offer 127.0.0.53 to the guest or container either. With this change, I'm only covering the case of automatically configured DNS servers from /etc/resolv.conf. We could extend this to addresses configured with command-line options, but I don't really see a likely use case at this point. Signed-off-by: Stefano Brivio --- dhcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dhcp.c') diff --git a/dhcp.c b/dhcp.c index 0c6f712..12da47a 100644 --- a/dhcp.c +++ b/dhcp.c @@ -359,9 +359,9 @@ int dhcp(const struct ctx *c, const struct pool *p) } for (i = 0, opts[6].slen = 0; - !c->no_dhcp_dns && !IN4_IS_ADDR_UNSPECIFIED(&c->ip4.dns[i]); + !c->no_dhcp_dns && !IN4_IS_ADDR_UNSPECIFIED(&c->ip4.dns_send[i]); i++) { - ((struct in_addr *)opts[6].s)[i] = c->ip4.dns[i]; + ((struct in_addr *)opts[6].s)[i] = c->ip4.dns_send[i]; opts[6].slen += sizeof(uint32_t); } -- cgit v1.2.3