Have already spent 4 hours trying to debug why DNS lookups do not work when the VM boots up.
Not only did I try to debug the problem manually, but went over hundreds of articles on the internet, including the solutions posted on Ask Ubuntu which by the way none worked.
I'm trying to build a VM template (Ubuntu Server 22.04) that I can easily clone inside VMware if I want a clean instance up and running.
DNS lookups start working when I run dhclient
but I don't wanna have that autostart on every boot, the configuration file should automatically pinpoint to the DNS server to be used instead of automagically configuring through dhclient
.
If using dhclient
is necessary than it defeats the purpose of the "manual configuration" in the first place.
I should also point out that I've done some preconfigurations in the /etc/systemd/network
directory correlating to the NAT, Host-Only and Bridge interfaces provided by VMware.
# cd /etc/systemd/network
# cat 001-nat.network
[Match]
Name=ens32
[Network]
Gateway=192.168.33.1
DNS=192.168.33.1
DHCP=yes
# cat 002-host-only.network
[Match]
Name=ens34
[Network]
Gateway=10.0.10.1
DHCP=yes
# cat 003-bridge.network
[Match]
Name=ens35
[Network]
Gateway=192.168.88.1
DHCP=yes
The reason I did this was because in the future I'd want VMs with static IP addresses and this is the way I know of setting it up.
Here is the output of ifconfig
, ip
, route
, resolvectl
and ping
before and after running dhclient
:
# =============== BEFORE ===============
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.33.4 netmask 255.255.255.0 broadcast 192.168.33.255
inet6 fe80::20c:29ff:feaa:6533 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:aa:65:33 txqueuelen 1000 (Ethernet)
RX packets 4 bytes 808 (808.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 1474 (1.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens34: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.10.6 netmask 255.255.255.0 broadcast 10.0.10.255
inet6 fe80::20c:29ff:feaa:653d prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:aa:65:3d txqueuelen 1000 (Ethernet)
RX packets 151 bytes 13923 (13.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 164 bytes 17651 (17.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens35: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.88.242 netmask 255.255.255.0 broadcast 192.168.88.255
inet6 fe80::20c:29ff:feaa:6547 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:aa:65:47 txqueuelen 1000 (Ethernet)
RX packets 49 bytes 4098 (4.0 KB)
RX errors 0 dropped 35 overruns 0 frame 0
TX packets 20 bytes 2038 (2.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# =============== AFTER ===============
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.33.4 netmask 255.255.255.0 broadcast 192.168.33.255
inet6 fe80::20c:29ff:feaa:6533 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:aa:65:33 txqueuelen 1000 (Ethernet)
RX packets 9 bytes 1958 (1.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 15 bytes 2500 (2.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens34: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.10.6 netmask 255.255.255.0 broadcast 10.0.10.255
inet6 fe80::20c:29ff:feaa:653d prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:aa:65:3d txqueuelen 1000 (Ethernet)
RX packets 206 bytes 18791 (18.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 202 bytes 23949 (23.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens35: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.88.242 netmask 255.255.255.0 broadcast 192.168.88.255
inet6 fe80::20c:29ff:feaa:6547 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:aa:65:47 txqueuelen 1000 (Ethernet)
RX packets 77 bytes 6471 (6.4 KB)
RX errors 0 dropped 53 overruns 0 frame 0
TX packets 26 bytes 2738 (2.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# =============== BEFORE ===============
default via 10.0.10.1 dev ens34 proto static onlink
default via 192.168.33.1 dev ens32 proto static onlink
default via 192.168.88.1 dev ens35 proto static onlink
default via 192.168.33.1 dev ens32 proto dhcp src 192.168.33.4 metric 1024
default via 192.168.88.1 dev ens35 proto dhcp src 192.168.88.242 metric 1024
1.0.0.1 via 192.168.88.1 dev ens35 proto dhcp src 192.168.88.242 metric 1024
1.1.1.1 via 192.168.88.1 dev ens35 proto dhcp src 192.168.88.242 metric 1024
10.0.10.0/24 dev ens34 proto kernel scope link src 10.0.10.6 metric 1024
10.0.10.1 dev ens34 proto dhcp scope link src 10.0.10.6 metric 1024
192.168.33.0/24 dev ens32 proto kernel scope link src 192.168.33.4 metric 1024
192.168.33.1 dev ens32 proto dhcp scope link src 192.168.33.4 metric 1024
192.168.88.0/24 dev ens35 proto kernel scope link src 192.168.88.242 metric 1024
192.168.88.1 dev ens35 proto dhcp scope link src 192.168.88.242 metric 1024
# =============== AFTER ===============
default via 192.168.88.1 dev ens35 proto static onlink
default via 192.168.88.1 dev ens35 proto dhcp src 192.168.88.242 metric 1024
1.0.0.1 via 192.168.88.1 dev ens35 proto dhcp src 192.168.88.242 metric 1024
1.1.1.1 via 192.168.88.1 dev ens35 proto dhcp src 192.168.88.242 metric 1024
10.0.10.0/24 dev ens34 proto kernel scope link src 10.0.10.6
192.168.33.0/24 dev ens32 proto kernel scope link src 192.168.33.4
192.168.88.0/24 dev ens35 proto kernel scope link src 192.168.88.242 metric 1024
192.168.88.1 dev ens35 proto dhcp scope link src 192.168.88.242 metric 1024
# =============== BEFORE ===============
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.10.1 0.0.0.0 UG 0 0 0 ens34
0.0.0.0 192.168.33.1 0.0.0.0 UG 0 0 0 ens32
0.0.0.0 192.168.88.1 0.0.0.0 UG 0 0 0 ens35
0.0.0.0 192.168.33.1 0.0.0.0 UG 1024 0 0 ens32
0.0.0.0 192.168.88.1 0.0.0.0 UG 1024 0 0 ens35
1.0.0.1 192.168.88.1 255.255.255.255 UGH 1024 0 0 ens35
1.1.1.1 192.168.88.1 255.255.255.255 UGH 1024 0 0 ens35
10.0.10.0 0.0.0.0 255.255.255.0 U 1024 0 0 ens34
10.0.10.1 0.0.0.0 255.255.255.255 UH 1024 0 0 ens34
192.168.33.0 0.0.0.0 255.255.255.0 U 1024 0 0 ens32
192.168.33.1 0.0.0.0 255.255.255.255 UH 1024 0 0 ens32
192.168.88.0 0.0.0.0 255.255.255.0 U 1024 0 0 ens35
192.168.88.1 0.0.0.0 255.255.255.255 UH 1024 0 0 ens35
# =============== AFTER ===============
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.88.1 0.0.0.0 UG 0 0 0 ens35
0.0.0.0 192.168.88.1 0.0.0.0 UG 1024 0 0 ens35
1.0.0.1 192.168.88.1 255.255.255.255 UGH 1024 0 0 ens35
1.1.1.1 192.168.88.1 255.255.255.255 UGH 1024 0 0 ens35
10.0.10.0 0.0.0.0 255.255.255.0 U 0 0 0 ens34
192.168.33.0 0.0.0.0 255.255.255.0 U 0 0 0 ens32
192.168.88.0 0.0.0.0 255.255.255.0 U 1024 0 0 ens35
192.168.88.1 0.0.0.0 255.255.255.255 UH 1024 0 0 ens35
# =============== BEFORE ===============
Global
Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: foreign
Current DNS Server: 1.1.1.1
DNS Servers: 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4
DNS Domain: localdomain
Link 2 (ens32)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 192.168.33.1
DNS Domain: localdomain
Link 3 (ens34)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 10.0.10.1
DNS Domain: localdomain
Link 4 (ens35)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 1.1.1.1 1.0.0.1
# =============== AFTER ===============
Global
Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: foreign
Current DNS Server: 1.1.1.1
DNS Servers: 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4
DNS Domain: localdomain
Link 2 (ens32)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 192.168.33.1
DNS Domain: localdomain
Link 3 (ens34)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 10.0.10.1
DNS Domain: localdomain
Link 4 (ens35)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 1.1.1.1 1.0.0.1
# =============== BEFORE ===============
PING google.com (142.250.180.206) 56(84) bytes of data.
--- google.com ping statistics ---
8 packets transmitted, 0 received, 100% packet loss, time 7174ms
# =============== AFTER ===============
PING google.com (142.250.180.206) 56(84) bytes of data.
64 bytes from bud02s33-in-f14.1e100.net (142.250.180.206): icmp_seq=1 ttl=116 time=20.7 ms
64 bytes from bud02s33-in-f14.1e100.net (142.250.180.206): icmp_seq=2 ttl=116 time=20.7 ms
64 bytes from bud02s33-in-f14.1e100.net (142.250.180.206): icmp_seq=3 ttl=116 time=20.4 ms
64 bytes from bud02s33-in-f14.1e100.net (142.250.180.206): icmp_seq=4 ttl=116 time=21.0 ms
64 bytes from bud02s33-in-f14.1e100.net (142.250.180.206): icmp_seq=5 ttl=116 time=26.2 ms
64 bytes from bud02s33-in-f14.1e100.net (142.250.180.206): icmp_seq=6 ttl=116 time=20.7 ms
64 bytes from bud02s33-in-f14.1e100.net (142.250.180.206): icmp_seq=7 ttl=116 time=20.8 ms
64 bytes from bud02s33-in-f14.1e100.net (142.250.180.206): icmp_seq=8 ttl=116 time=22.2 ms
--- google.com ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7012ms
rtt min/avg/max/mdev = 20.400/21.588/26.168/1.806 ms
VMware NAT Configuration:

I am new to Linux, so I apologize if I'm missing out on some important detail in the configuration. This isn't the first time I encountered this problem.