[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: NetworkManager and systemd-networkd/systemd-resolved



On 1/28/2020 5:27 PM, Christoph Pleger wrote:
> Hello,
>
>> on my notebook computer, I have a WLAN interface that is managed with
>> NetworkManager and a cable-bound network interface that gets its
>> static IP address by a systemd-networkd configuration file. But as of
>> course on a portable notebook the cable-bound network interface is not
>> always connected, it is a additionally also managed by NetworkManager.
>> Hostname resolution takes place through systemd-resolved, that is,
>> /etc/resolv.conf is a symbolic link to
>> /run/systemd/resolve/stub-resolv.conf .
>>
>> This all works fine so far, but when the cable-bound interface is not
>> connected (that means, when NetworkManager de-activated the
>> connection), the nameservers defined for that connection in the
>> systemd-networkd configuration file are still in the active
>> systemd-resolved configuration, as can be seen in the file
>> /run/systemd/resolve/resolv.conf and in the output of "resolvectl
>> status". Though this is - at least in my case with maximum of three
>> nameservers - only a cosmetic problem, my goal is that the nameservers
>> defined for the cable-bound connection disappear from the active
>> systemd-resolved configuration when the cable is disconnected.
>>
>> Is it possible to realize such a combination of NetworkManager and
>> systemd-networkd/systemd-resolved?
>
>
> networkd-dispatcher can execute actions on network connection state
> changes, so can probably help to reach my goal, what I need now is a
> command to directly remove the DNS servers from systemd-resolved
> configuration or a command that de-activates a certain interface from
> systemd-networkd's point of view and thereby deletes the corresponding
> DNS servers from systemd-resolved configuration. The latter can be done
> by systemctl stop systemd-networkd, but only for a short time, because
> then, systemd-networkd is restarted automatically.
>

My two cents, given that you have NM installed would be to disable
systemd-networkd and systemd-resolved and let NetworkManager handel your
interfaces and DNS.

$ systemctl disable systemd-networkd systemd-resolved


If you do the above command, you will probably loose remote connection
to the host after a reboot.

You can also use the 'nmcli' to control NM from the command line.

--
John Doe


Reply to: