DHCP proxy doesn't set advertised DNS servers
agorgl opened this issue · comments
As per the current implementation, it seems that the nameservers in the container's /etc/resolv.conf
are copied from the host's /etc/resolv.conf
. It would be nice if netavark-dhcp-proxy
somehow assigned to each container the DNS servers provided by their respective DHCP requests.
This would play really nice with scenarios where the host is in a different VLAN+subnet (e.g. management
VLAN) than the containers (e.g. services
VLAN) and each VLAN has its own DHCP server with different advertised DNS server.
Yeah that should be possible to do, are you interested in opening a PR to fix it?
The core infra for sending the dns servers back to podman is already there.
You would only need to change get_dhcp_lease()
to also return the dns servers (the should already be part of the lease)
netavark/src/network/macvlan_dhcp.rs
Line 28 in 73946c8
Then just set response.dns_server_ips = ...
were it is called to add the servers to the response. This is then send to podman and podman knows how to configure resolv.conf based on this. Also we would need to ensure podman run --dns ...
will still take precedent over the dhcp response.