[Networkmanager] Dynamically changing DNS configurations depending on the connection

Andre Costa andre.ocosta at gmail.com
Thu Aug 10 13:22:10 UTC 2023


Hi,

There is a lot of context here
<https://discussion.fedoraproject.org/t/need-to-set-different-dns-configurations-for-home-and-work/86830>,
but to summarize the current status:

   1. There are two specific scenarios that I am trying to manage through
   dispatcher scripts:
      1. Wired connection needs to set up different DNS configurations
      depending if I am working remotely from home or at the office
      2. When I am working remotely and I connect through the VPN to
      work.com, I need to set up split DNS to route queries to <site>.
      work.com to work.com DNS servers, and all other queries to NextDNS
      servers
      2. I am configuring everything I can through NetworkManager's profiles
      1. I have one profile for wired connection that is used both at home
      and at the office
      2. I have two profiles to connect to my work VPN
      3. I have two profiles for Wi-Fi (one for home and the other for work)

I think I managed to solve 1.1 through a dispatcher script, but I haven't
tested it onsite yet.

As for 1.2, I wrote another dispatcher script that is being executed, but
for some unknown reason, the changes I am making through resolvectl are
being reversed:

Aug 09 12:19:23 fedoracosta systemd-resolved[950]: enp3s0: Bus client set
DNS server list to: ...
Aug 09 12:19:23 fedoracosta systemd-resolved[950]: enp3s0: Bus client set
search domain list to: ~.
Aug 09 12:19:23 fedoracosta systemd-resolved[950]: enp3s0: Bus client set
default route setting: yes
Aug 09 12:19:23 fedoracosta systemd[1]: iscsi.service: Unit cannot be
reloaded because it is inactive.
Aug 09 12:19:25 fedoracosta systemd-resolved[950]: enp3s0: Bus client reset
search domain list.
Aug 09 12:19:25 fedoracosta systemd-resolved[950]: enp3s0: Bus client set
default route setting: no
Aug 09 12:19:25 fedoracosta systemd-resolved[950]: enp3s0: Bus client reset
DNS server list.

On the output above, the first three lines are the result of the execution
of the dispatcher script, and the last three lines revert them. If I try to
apply the same changes through the command line after the VPN is up, it
works as intended.

I think I am stuck here, if anyone could lend a helping hand, I would
greatly appreciate it.

Best regards,
Andre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/networkmanager/attachments/20230810/ed0ee372/attachment.htm>


More information about the Networkmanager mailing list