Artix Linux Forum

Artix Linux => System => Topic started by: rockybulwinkle on 27 November 2018, 01:16:00

Title: [SOLVED] NetworkManager does not set my custom DNS
Post by: rockybulwinkle on 27 November 2018, 01:16:00
I've set a custom DNS in my network manager because by default it doesn't seem to resolve most addresses when I use NetworkManager instead of some wpa_supplicant scripts. For example:
Code: [Select]
[rocky@cassini ~]$ ping asdf.om
ping: asdf.om: Name or service not known

My /etc/resolv.conf:
Code: [Select]
# Generated by NetworkManager
nameserver fda6:ec2c:8511::1

Thanks
Title: Re: NetworkManager does not set my custom DNS
Post by: mrbrklyn on 27 November 2018, 11:44:20
I've set a custom DNS in my network manager because by default it doesn't seem to resolve most addresses when I use NetworkManager instead of some wpa_supplicant scripts. For example:
Code: [Select]
[rocky@cassini ~]$ ping asdf.om
ping: asdf.om: Name or service not known

My /etc/resolv.conf:
Code: [Select]
# Generated by NetworkManager
nameserver fda6:ec2c:8511::1

Thanks


are you using a dhcp server?  There is not enough information here.  All DNS is custom....
Title: Re: NetworkManager does not set my custom DNS
Post by: rockybulwinkle on 27 November 2018, 17:19:45
I'm using DHCP on my router. The script I mentioned use use wpa_supplicant and dhcpcd to connect and get an IP.

Those scripts set up my router as my DNS. Since NetworkManager wasn't working out of the box (I could access, say, google.com but not asdf.com) I tried setting the DNS in the IPv4 settings to 1.1.1.1 and my /etc/resolv.conf still only had that ipv6 address and websites still weren't resolving.

I can give more information when I get home, this computer isn't in front of me right now.

Thanks
Title: Re: NetworkManager does not set my custom DNS
Post by: fungalnet on 27 November 2018, 18:59:57
You should specify always when presenting an issue if you are running on OpenRC or Runit.
# ip a
should show you what interfaces you have and if they are active
Other than dhcpcd you need dhcpcd-runit/openrc and activate them.
# dhcpcd
Will start it anyhow.

One of the reasons I stopped using nm is because it loves to rewrite my settings to its own, and dns was part of my problem.
I also use net-tools and ifconfig in particular to activate intefaces and deactivate them.
example:
# ifconfig eth0 up
# ifconfig wlan0 down

Title: Re: NetworkManager does not set my custom DNS
Post by: mrbrklyn on 27 November 2018, 19:12:46
You should specify always when presenting an issue if you are running on OpenRC or Runit.
# ip a
should show you what interfaces you have and if they are active
Other than dhcpcd you need dhcpcd-runit/openrc and activate them.
# dhcpcd
Will start it anyhow.

One of the reasons I stopped using nm is because it loves to rewrite my settings to its own, and dns was part of my problem.
I also use net-tools and ifconfig in particular to activate intefaces and deactivate them.
example:
# ifconfig eth0 up
# ifconfig wlan0 down



DHCPCD is vixies DHCPCD FWIW and network manager usually uses dhcpclient

FWIW, 1.1.1.1 is a dns server outside of your network owned by digital ocean if I am not mistaken.  Aside from the problems involved with depending on them, the fact that you are not reaching them seems to me tat your routing is messed up, and possibly the wifi if you are using it.
Title: Re: NetworkManager does not set my custom DNS
Post by: rockybulwinkle on 28 November 2018, 03:19:04
I'm using openrc. I have installed the init scripts for Network Manager already.

I think the topic name might be misleading. All I really want is my DNS to work. I had tried to set it manually to cloudflare's (1.1.1.1) but it didn't work.

Other devices on my network are working fine including a phone and nintendo switch on wifi as well as an Artix desktop on ethernet. The only thing not working right now is my laptop when I use networkmanager.

Networkmanager is configuring the ipv6 DNS correctly to point at my router. The ipv4 dns entry is missing from resolv.conf. My phone, nintendo switch, and desktop all are getting their ipv4 DNS set to the router correctly so it isn't a problem with the router.
Title: Re: NetworkManager does not set my custom DNS
Post by: rockybulwinkle on 28 November 2018, 04:59:39
If I manually run dhclient after NetworkManager has finished getting an ipv6 lease I get an ipv4 lease and my dns and gateway is set right.

This is sounding suspiciously like this issue over at Manjaro: https://forum.manjaro.org/t/no-ipv4-with-wifi/13359/16
Title: Re: NetworkManager does not set my custom DNS
Post by: rockybulwinkle on 28 November 2018, 05:07:33
The second response here worked for me! https://bugzilla.redhat.com/show_bug.cgi?id=1468358

The one about changing the dhcp client identifier:
Quote
Does it work if you change the client-identifier of the connection to a type+mac one? i.e.:

 nmcli connection mod <connection-name> ipv4.dhcp-client-id 01:xx:xx:xx:xx:xx:xx
 nmcli connection up <connection-name>

where xx:xx:xx:xx:xx:xx is a MAC address?

Why isn't it doing this by default? *edit* or is this simply masking a problem?
Title: Re: NetworkManager does not set my custom DNS
Post by: mrbrklyn on 28 November 2018, 15:01:01

That is not relavent
Quote
I have installed the init scripts for Network Manager already.

That should have been installed with the OS installation.  Why this needs to be done by hand is a puzzle.

Quote
I think the topic name might be misleading. All I really want is my DNS to work. I had tried to set it manually to cloudflare's (1.1.1.1) but it didn't work.

If you have no network you can't get DNS and DNS is often set by a DHCP application, either by networkmanger or by the init scripts directly

You also must be on the broadcast leg of the network that has the DHCP server, or your are shouting into the wind.

Quote
Other devices on my network are working fine including a phone and nintendo switch on wifi as well as an Artix desktop on ethernet.

I'm tempted to say I don't care, but I will be polite and say it doesn't matter.

Quote
The only thing not working right now is my laptop when I use networkmanager.

FWIW, the most likely point of failure here is the wifi connection.  Check the network with ifconfig


Quote
Networkmanager is configuring the ipv6 DNS correctly to point at my router.

How do you know that?

Quote
The ipv4 dns entry is missing from resolv.conf. My phone, nintendo switch, and desktop all are getting their ipv4 DNS set to the router correctly so it isn't a problem with the router.

Is network manager started?
Title: Re: NetworkManager does not set my custom DNS
Post by: mrbrklyn on 28 November 2018, 15:03:06
BTW - I always start dhcpcd by hand because I hate playing with Networkmanger.  It has enough trouble just keeping the wifi up..
Title: Re: NetworkManager does not set my custom DNS
Post by: rockybulwinkle on 28 November 2018, 15:38:18
fungalnet asked.
That should have been installed with the OS installation.  Why this needs to be done by hand is a puzzle.
I installed only the base system and then cinnamon. I never said I needed to install it by hand.

If you have no network you can't get DNS and DNS is often set by a DHCP application, either by networkmanger or by the init scripts directly
Yeah, figured that out already

I'm tempted to say I don't care, but I will be polite and say it doesn't matter.
Other devices work fine. That was my point, refuting that my router was the issue. Saying "I'll be polite" doesn't make it polite.

FWIW, the most likely point of failure here is the wifi connection.  Check the network with ifconfig
dd

See my /etc/resolv.conf in my first post.

Of course it is, otherwise I wouldn't even have gotten that far.

Did you not read my last post? Setting the DHCP client id fixed it.
Title: Re: NetworkManager does not set my custom DNS
Post by: mrbrklyn on 29 November 2018, 03:04:45
Can we move this thread to Configurations please .... sorry for the Meta discussion.
Title: Re: NetworkManager does not set my custom DNS
Post by: mrbrklyn on 29 November 2018, 03:07:36


Did you not read my last post? Setting the DHCP client id fixed it.


Yes, I did read it.  It is often the case that it works when you run it by hand.  I think the question you have now is why Network manager doesn't do it automatically, or do you consider the issue solved now?
Title: Re: NetworkManager does not set my custom DNS
Post by: mrbrklyn on 29 November 2018, 03:10:58
See my /etc/resolv.conf in my first post.



I read that and to me it just looked broken with an IP6 address.  What is the address of the DNS that it is supposed to point to?
Title: Re: NetworkManager does not set my custom DNS
Post by: rockybulwinkle on 29 November 2018, 05:51:22
Is moving the thread something I need to do or does a mod need to do it?
Sorry, this post might feel a bit disjointed. It's getting late here.

I think I found the problem, same as this person's: https://forum.artixlinux.org/index.php/topic,701.msg5433.html#msg5433

When I set my dbus machine-id, networkmanager sets the ipv4 dns correctly without my setting the dhcp client id. It isnt' automatically setting it to the 01:<mac address>, it's still not set like it did without machine-id. My best guess is that it is trying to talk to dhclient over dbus and it can't without the machine-id being set.

For whatever reason the dbus install scripts don't set /etc/machine-id or /var/lib/dbus/machine-id. dbus-uuidgen > /etc/machine-id. I had a similar problem with KDE plasma a week ago but I must have accidentally reverted that fix at some point.

So I guess the real question is, why isn't the dbus machine-id getting set? I think this is the answer: https://www.reddit.com/r/archlinux/comments/6kwt61/systemd_doesnt_create_machineid_during/

Sounds like normally the machine-id is set by systemd-firstboot according to the arch folks. If that's really the case, I would think folk who migrated arch linux would not have this issue, but since I installed it fresh from the artix livecd mine isnt' set.

And btw I confirmed, that ipv6 in my resolv.conf was my router's ipv6 on my lan. Going back to my example websites I used in the first post, google.com can resolve with "ping -6" but asdf.com can't. My ipv6 DNS was working the whole time. Just not ipv4.

In any case, I'm going to mark this as solved, though I'm going to open up another issue about the systemd-firstboot and dbus's machine-id.
Title: Re: NetworkManager does not set my custom DNS
Post by: rockybulwinkle on 29 November 2018, 06:09:13
And now inexplicably *something* is setting my /etc/machine-id on poweroff/reboot. I'm not sure what could be doing it now. It definitely wasn't there before when I was having the DNS issues though.

I may do more investigating tomorrow. I may rollback or reinstall artix to a different btrfs subvol and see if the problem happens still on a completely fresh install.
Title: Re: NetworkManager does not set my custom DNS
Post by: rockybulwinkle on 29 November 2018, 06:17:26
Yes, I did read it.  It is often the case that it works when you run it by hand.  I think the question you have now is why Network manager doesn't do it automatically, or do you consider the issue solved now?
I think you may have misunderstood here btw. I mean I modified the networkmanager connection profile using nmcli to set the ipv4.dhcp-client-id to 01:<mac addr>. But in any case, the right fix is setting machine-id.
Title: Re: NetworkManager does not set my custom DNS
Post by: physkets on 30 November 2018, 09:19:01
If you don't want NetworkManager to control DNS, set the following in /etc/NetworkManager/NetworkManager.conf :

Code: [Select]
[main]
dns=none

If you want want to know more, look at: 
Code: [Select]
$ man 5 NetworkManager.conf
Title: Re: NetworkManager does not set my custom DNS
Post by: rockybulwinkle on 01 December 2018, 02:56:53
Thanks for the tip. I'm fine with networkmanager controlling my DNS now that it is being set correctly.
Title: Re: NetworkManager does not set my custom DNS
Post by: mrbrklyn on 01 December 2018, 23:50:23
Is moving the thread something I need to do or does a mod need to do it?
Sorry, this post might feel a bit disjointed. It's getting late here.

I think I found the problem, same as this person's: https://forum.artixlinux.org/index.php/topic,701.msg5433.html#msg5433

When I set my dbus machine-id, networkmanager sets the ipv4 dns correctly without my setting the dhcp client id. It isnt' automatically setting it to the 01:<mac address>, it's still not set like it did without machine-id. My best guess is that it is trying to talk to dhclient over dbus and it can't without the machine-id being set.

For whatever reason the dbus install scripts don't set /etc/machine-id or /var/lib/dbus/machine-id. dbus-uuidgen > /etc/machine-id. I had a similar problem with KDE plasma a week ago but I must have accidentally reverted that fix at some point.

So I guess the real question is, why isn't the dbus machine-id getting set? I think this is the answer: https://www.reddit.com/r/archlinux/comments/6kwt61/systemd_doesnt_create_machineid_during/

Sounds like normally the machine-id is set by systemd-firstboot according to the arch folks. If that's really the case, I would think folk who migrated arch linux would not have this issue, but since I installed it fresh from the artix livecd mine isnt' set.

And btw I confirmed, that ipv6 in my resolv.conf was my router's ipv6 on my lan. Going back to my example websites I used in the first post, google.com can resolve with "ping -6" but asdf.com can't. My ipv6 DNS was working the whole time. Just not ipv4.

In any case, I'm going to mark this as solved, though I'm going to open up another issue about the systemd-firstboot and dbus's machine-id.


DNS really doesn't need anything with machine ids, and has nothing to do with dbus.  Other aspects of Network Manager might need dbus, like wifi firmware identificaation etc etc, but DNS is a TCP/IP client and so is DHCP
Title: Re: NetworkManager does not set my custom DNS
Post by: rockybulwinkle on 06 December 2018, 02:21:06
I agree, dns does not directly have anything to do with dbus. But the system components that are managing this don't work when the machine-id isn't set is all I'm saying.
Title: Re: NetworkManager does not set my custom DNS
Post by: rockybulwinkle on 06 December 2018, 03:01:37
I went ahead and did my experiment:

I went back to my btrfs snapshot I did after my initial install

I updated it with pacman -Syyu and rebooted.

I changed it from runit to openrc.

I installed networkmanager-openrc and cinnamon.

I checked my /etc/machine-id. It was empty.

I added networkmanager to the default runlevel and rebooted.

I connected to my wifi network.

I checked /etc/resolv.conf. No ipv4 nameserver.

I did "dbus-uuidgen > /etc/machine-id"

I rebooted.

I connected to the network and checked my /etc/resolv.conf again. There was an ipv4 nameserver now pointing to my router.

So a missing machine-id is causing networkmanager to fail to set the ipv4 nameserver in resolv.conf.

I don't think there's anything else to say here. This thread ought to be closed.
Title: Re: NetworkManager does not set my custom DNS
Post by: rockybulwinkle on 06 December 2018, 03:36:46
Ok, maybe one more thing to say. I'm looking at network manager's source code here: https://github.com/NetworkManager/NetworkManager/blob/master/src/nm-core-utils.c . It does have references to /etc/machine-id in it. I would have to read a lot more code to be certain, but it seems probable that the code that generates the dhcp client id fails if /etc/machine-id is empty.
Title: Re: [SOLVED] NetworkManager does not set my custom DNS
Post by: TopHatProductions115 on 21 December 2022, 08:34:06
Replied to the wrong thread. Please forgive my error.