Closed aharshac closed 1 month ago
Adding your nameservers into the netplan configuration is not supposed to update /etc/resolv.conf
. This file should be a symlink to /run/systemd/resolve/stub-resolv.conf
which in turn should not be edited. If you have made changes to these two files then please reset them by:
/run/systemd/resolve/stub-resolv.conf
/etc/resolv.conf
is still a symlink to /run/systemd/resolve/stub-resolv.conf
(you can use ls -l /etc | grep resolv
on the directory to verify this)To add DNS nameservers you will have to know which network backend the network interface is being managed by.
resolvectl status
. This command will show the DNS Servers for each network interface. Additional Note: If you happen to have connected a device with a DHCP server (such as a router) to eth0 then you may also need to use DHCP Overrides to set use-dns
to false in the netplan configuration file so that the router does not override the nameservers. (These instructions are specific to networkd, and can be done for NetworkManager using the nmcli tool).
@hilary-luo I'm using the wlan0 interface and set the nameservers in /etc/netplan/50-wifis.yaml
network:
version: 2
wifis:
renderer: NetworkManager
wlan0:
access-points:
ABC-network:
band: 2.4GHz
password: 32caaeea
addresses:
- 192.168.1.103/24
dhcp4: true
optional: true
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
sudo netplan apply
resolvectl status
Global
Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (eth0)
Current Scopes: none
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Link 3 (usb0)
Current Scopes: none
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Link 4 (wlan0)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 8.8.8.8 8.8.4.4 192.168.1.1
Thanks for the help!
Given that this issue is now closed I assume you have figured it out but I would like to follow up for anyone who comes across this. The wifi connection shown is managed by the NetworkManager renderer and as such you should be using the nmcli tool to set the nameservers, not the netplan method.
@hilary-luo Will the DNS changes made with nmcli persist after a reboot?
I believe they should but I would encourage you to test it yourself.
Robot Model
Turtlebot4 Standard
ROS distro
Humble
Networking Configuration
Discovery Server
OS
Ubuntu 22.04
Built from source or installed?
Installed
Package version
Type of issue
Networking
Expected behaviour
Added a nameserver to
/etc/resolv.conf
, but it disappeared after a reboot.As suggested in that file, I then added it to
/run/systemd/resolve/stub-resolv.conf
and it did not show up in/etc/resolv.conf
after runningsudo systemctl restart systemd-resolved
.Tried adding it to
/etc/netplan/40-ethernets.yaml
and then ransudo netplan apply
, but it still did not show up in/etc/resolv.conf
.Actual behaviour
DNS nameservers shall be added to
/etc/resolv.conf
Error messages
No response
To Reproduce
/etc/resolv.conf
,/run/systemd/resolve/stub-resolv.conf
or/etc/netplan/40-ethernets.yaml
sudo systemctl restart systemd-resolved
, or runsudo netplan apply
respectivelycat /etc/resolv.conf
DNS nameserver is missing in
/etc/resolv.conf
Other notes
No response