[Networkmanager] Sending DNS servers on interface without default router to systemd-resolved when all active interfaces with default router failed connectivity check

Arseniy Lartsev arseniy.lartsev at qodes.se
Thu Mar 23 18:41:38 UTC 2023


Hello,

I have a funky setup where there is 4G modem that only receives LAN IP configuration (let's say 172.16.0.0/16, without any default router) but with a DNS server, and also ethernet and wi-fi adapters that may have Internet connection. And then there is one specific server my software accesses (let's call it www.backend.com) that's available on the Internet (any normal DNS server will resolve www.backend.com to its public IP address) but also available over the modem because modem's DNS server will resolve www.backend.com to a 172.16.x.x address.

I'm also using systemd-resolved to manage DNS requests for the rest of the user space. Now, if ethernet or wi-fi adapter has Internet connection, NetworkManager will send only DNS servers of that network interface (or link, in resolved's terms) to systemd-resolved, and for the modem interface (link ppp0) empty list of DNS servers is sent, so that any application will resolve www.backend.com to an Internet IP address and will therefore access it using ethernet/wi-fi. And if both ethernet and wi-fi are disconnected, then NetworkManager will change its mind and actually send modem's DNS server to systemd-resolved, applications will resolve www.backend.com to 172.16.x.x and access it over the modem. So far, so good.

However, I'm also using connectivity checking in NetworkManager, and I would like to switch to the modem, similar to the above, not just if ethernet and wi-fi are disconnected, but also if they are active but lose Internet connection and then fail connectivity check. And here I get in trouble as connectivity checks have no bearing on what's being sent to systemd-resolved, and thus applications will either keep resolving www.backend.com to its Internet address and then try and fail to access it over Internet, or even fail to resolve it. What I would like to do is treat an interface that failed connectivity check as if it was disconnected for the purpose of sending DNS servers to systemd-resolved.

Now, to the questions:

* Any tips on how to achieve this?
* Do I have to patch NetworkManager?
* If yes, could you perhaps point me to relevant parts of its source code and give some hints?

Any help is much appreciated.

P.S. A proud user of NetworkManager on an embedded system.





More information about the Networkmanager mailing list