I have an box running Ubuntu 18.04.4. There are two LAN interfaces enp3s0 and eno1: the former is connected to a 3G modem on LAN network and the latter is connected to a satellite modem on another network. Network Manager takes care of setting priority to the interfaces through Connectivity Check setting in its configuration file (let's say, in case of no 3G coverage eno1 interface metrics is downgraded by adding 20000 to its default value and same applies to enp3s0 in case of no satellite - default priority is higher on eno1 with both connections active). DNS is handled by systemd-resolved and systemd-networked. Both interfaces are getting their IP addresses and DNS from DHCP services run on 3G and satellite modems. enp3s0: IP 192.168.200.101 (DNS/GW: 192.168.200.101) - this address is assigned permanently via MAC address assignment eno1: IP 192.168.55.xxx (DNS/GW: 192.168.55.1)
Somehow DNS server address supplied to the first interface takes priority over the second one. E.g., if enp3s0 does not have internet connection and internet traffic is routed to 192.168.55.1, name resolution is still attempted via 192.168.200.1 and obviously fails. I tried replacing dynamically assigned DNS for eno1 with a static DNS added to /etc/systemd/network/eno1.network
[Match]
Name=eno1
[Network]
DNS=8.8.8.8
DNS=8.8.4.4
But the system still prefers to use 192.168.200.1 for name resolution. I added a global fallback DNS to /etc/systemd/resolved.conf but it does not seem to help if even taken into account.
[Resolve]
#DNS=
FallbackDNS=8.8.4.4
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes
What I would like to achieve is to not use only 192.168.200.1 as the DNS server but in case it does not work to use the DNS server associate with the second interface but I am failing to find the way. My understanding it is somehow related to how the first DNS is configured, it got that ~ in its domain assignment what I suspect makes it the main source of internet names but may be I am dreaming. Any advice on that is highly appreciated, basically how can I get both DNSs working? Below is my resolved status output where I see that ~ (with Google DNS assigned to 2nd iface).
Global
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.in-addr.arpa
17.172.in-addr.arpa
18.172.in-addr.arpa
19.172.in-addr.arpa
20.172.in-addr.arpa
21.172.in-addr.arpa
22.172.in-addr.arpa
23.172.in-addr.arpa
24.172.in-addr.arpa
25.172.in-addr.arpa
26.172.in-addr.arpa
27.172.in-addr.arpa
28.172.in-addr.arpa
29.172.in-addr.arpa
30.172.in-addr.arpa
31.172.in-addr.arpa
corp
d.f.ip6.arpa
home
internal
intranet
lan
local
private
test
Link 15 (tun0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 14 (veth2e5ae19)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 12 (veth5b411fa)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 10 (br-b950c350c024)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 9 (docker0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 8 (can0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 7 (wlp1s0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 6 (wwp0s20u6i10)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 5 (wwp0s20u6i8)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 4 (enp3s0)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 192.168.200.1
DNS Domain: ~.
rig
Link 3 (enp2s0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 2 (eno1)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 8.8.8.8
8.8.4.4