Can I have per-network DNS servers with DNSMasq?

1

I'm using DNSMasq. For some wifi networks I need to have different DNS servers. By default I have the Quad9 DNS addresses. But when I connect to my university network (eduroam) I have to use their provided DNS servers -- Quad9 is blocked.

Is there a way to get the suggested DNS server from the router when I connect, and use that? Ideally I'd like to be able to set whether I want to use their suggestion.

Currently I add a rule to a dnsmasq.d/ directory, and restart dnsmasq whenever I connect, and then remove the file and restart when I disconnect.


I'm using Arch Linux. For network management I use netctl.

blueteeth

Posted 2019-01-24T15:37:37.597

Reputation: 111

It depends a lot on your client operating system, since the easiest way to accomplish your goal (if I'm understanding it correctly) is to not use dnsmasq at all for eduroam. You can usually accomplish that using your OS's built-in network configuration, so it would help to specify what that is. – Adrian Petrescu – 2019-01-24T17:27:08.543

Arch Linux. netctl. I tried using ExecUpPre to reconfigure dnsmasq when connecting to eduroam, but it didn't work. It never seemed to get called, or if it did, the required DNS servers would be after Quad9. – blueteeth – 2019-01-24T17:43:37.333

Answers

0

Yoyr confuguration is unclear to me, but im pretty certain the solution lies in the DHCP client you are running.

DHCP typically provides the connection information for (dynamically assigned) IP addresses, and typically includes the nameservers. It sounds like in your setup (which is not that uncommon in Linux) the DHCP requests as far as they pertain to DNS are being ignored - which makes some sense if you are lically running DNSMASQ.

If you are running isc dhcp (which is very common) there is a hook you can use to control what DHCP does with DNS information. The man page (https://www.isc.org/wp-content/uploads/2018/02/dhcp44cscript.html) has more info on this hook.

By editing how resolv.conf looks you can change the nameserver.

davidgo

Posted 2019-01-24T15:37:37.597

Reputation: 49 152