my Ubuntu 18.04 laptop is connected to a WiFi with DHCP but I want to manual set a unique DNS server into the network.
When I set /etc/resolv.conf with the following configuration it works well, but as you know this settings are temporarily:
#nameserver 127.0.0.53
#options edns0
nameserver 192.168.1.50
Results:
$ nslookup router.home.com
Server: 192.168.1.50
Address: 192.168.1.50#53
Name: router.home.com
Address: 192.168.1.1
To make this settings permanent I found that I can use netplan but didn't work to me as you can see next:
nslookup router.home.com Server: 127.0.0.53 Address: 127.0.0.53#53 ** server can't find router.home.com: NXDOMAIN
My current configurations are:
$ ip addr
3: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:23:4e:26:36:3e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.43/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp1s0
valid_lft 84380sec preferred_lft 84380sec
inet6 fe80::340e:32d:6bf5:a2cc/64 scope link noprefixroute
valid_lft forever preferred_lft forever
Netplan config:
$ ls /etc/netplan
01-network-manager-all.yaml
sudo nano /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
wifis:
wlp1s0:
dhcp4: yes
dhcp4-overrides:
use-dns: no
access-points:
"**SSID**":
password: "**PASSWORD**"
nameservers:
addresses: [192.168.1.50]
This was the output applying the changes:
$ sudo netplan apply
$ sudo netplan --debug apply
** (generate:12411): DEBUG: 14:56:58.874: Processing input file /etc/netplan/01-network-manager-all.yaml..
** (generate:12411): DEBUG: 14:56:58.874: starting new processing pass
** (generate:12411): DEBUG: 14:56:58.874: wlp1s0: adding wifi AP '**SSID**'
** (generate:12411): DEBUG: 14:56:58.874: wlp1s0: setting default backend to 2
** (generate:12411): DEBUG: 14:56:58.874: Configuration is valid
** (generate:12411): DEBUG: 14:56:58.874: Generating output files..
** (generate:12411): DEBUG: 14:56:58.874: networkd: definition wlp1s0 is not for us (backend 2)
DEBUG:no netplan generated networkd configuration exists
DEBUG:netplan generated NM configuration changed, restarting NM
DEBUG:wlp1s0 not found in {}
DEBUG:Merged config:
network:
bonds: {}
bridges: {}
ethernets: {}
vlans: {}
wifis:
wlp1s0:
access-points:
**SSID**:
password: **PASSWORD**
dhcp4: true
dhcp4-overrides:
use-dns: false
nameservers:
addresses:
- 192.168.1.50
DEBUG:Skipping non-physical interface: lo
DEBUG:Skipping non-physical interface: enp2s1
DEBUG:{}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for enp2s1
DEBUG:netplan triggering .link rules for wlp1s0
Testing I could found any change:
$ systemd-resolve --status
Global
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.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 3 (wlp1s0)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 192.168.1.1
Link 2 (enp2s1)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Even though I disabled systemd-resolved service, NetworkManager also dynamically modifies the symbolic link resolv.conf, I fixed that with:
$ sudo rm /etc/resolv.conf
Editing resolv.conf:
$ sudo nano /etc/resolv.conf
nameserver ::1
nameserver 127.0.0.1
nameserver 192.168.1.1
And I put the overwrite protection flag: $ sudo chattr +i /etc/resolv.conf
Permissions:
$ ls -al /etc/resolv.conf
-rw-r--r-- 1 root root 71 jul 18 17:24 /etc/resolv.conf
%
Thank you in advance