No internet on boot: resolvectl + dhclient commands to solve on each boot. why?

Since a couple of days ago when I start from suspension or boot my ubuntu laptop I have no DNS, no internet connection, I can only ping routes defined in /etc/hosts like a localnetwork server.

I am forced to:
resolvectl revert 3
resolvectl revert 4
sudo dhclient wlp0s20f3

After that, the WIFI symbol in the status bar comes up (before the commands there is always a network symbol, but I have no ethernet cable connected). and After the commands everything works.

BTW: revert 3 and 4 are just: Link 3 (ipv6leakintrf0) and Link 4 (pvpnksintrf0)

Check your netplan config.

ls /etc/netplan/

I have file named 01-network-manager-all.yaml in that dir. Can you paste contains of it?

cat /etc/netplan/01-network-manager-all.yaml

Here is the contents of the only file "01-network-manager-all.yaml
" in the directory:

network:
  version: 2
  renderer: NetworkManager

Make sure the NetworkManager service is enabled at boot time. Here is how to check:

systemctl is-enabled NetworkManager

Is it disabled? If so, enable it:

sudo systemctl enable NetworkManager

Next, make sure your wifi connection is listed here:

nmcli -p device
nmcli device status

# Is wifi enabled?
nmcli general status

# Viewing all connections
nmcli connection show

To view the available wifi access points and SSID:

nmcli dev wifi list

Here is how to connect to a password-protected wifi network:

nmcli --ask device wifi connect "YOUR_SSID_HERE"

You can see WiFi auto connect and NetworkManger management status:

nmcli -p -f general,wifi-properties device show YOUR_WIFI_DEVICE_NAME

# To find your WIFI device name run
nmcli -p device

# Then see properties (say device name is wlp82s0)
nmcli -p -f general,wifi-properties device show wlp82s0
nmcli -p device show wlp82s0 | more

Make sure the following two are enabled/yes:

GENERAL.NM-MANAGED: yes
GENERAL.AUTOCONNECT: yes

There is a GUI too if you are using Desktop. Just open Settings and WiFi. Make sure Wi-Fi is enabled if using GUI:

it is in fact enabled.

DEVICE             TYPE      STATE         CONNECTION               
------------------------------------------------------------------------------------------
wlp0s20f3          wifi      connected     EasyBox-2EB344 1         
ipv6leakintrf0     dummy     connected     pvpn-ipv6leak-protection 
pvpnksintrf0       dummy     connected     pvpn-killswitch          
br-e2a94ac4df51    bridge    connected     br-e2a94ac4df51          
docker0            bridge    connected     docker0                  
p2p-dev-wlp0s20f3  wifi-p2p  disconnected  --                       
veth5591bfe        ethernet  unmanaged     --                       
veth9bb9c0c        ethernet  unmanaged     --                       
lo                 loopback  unmanaged     --           

STATE CONNECTIVITY WIFI-HW WIFI WWAN-HW WWAN
connected full enabled enabled enabled enabled

===============================================================================
                          Device details (wlp0s20f3)
===============================================================================
GENERAL.DEVICE:                         wlp0s20f3
GENERAL.TYPE:                           wifi
GENERAL.NM-TYPE:                        NMDeviceWifi
GENERAL.DBUS-PATH:                      /org/freedesktop/NetworkManager/Devices/2
GENERAL.VENDOR:                         Intel Corporation
GENERAL.PRODUCT:                        --
GENERAL.DRIVER:                         iwlwifi
GENERAL.DRIVER-VERSION:                 5.14.0-1057-oem
GENERAL.FIRMWARE-VERSION:               63.c04f3485.0 QuZ-a0-hr-b0-63.u
GENERAL.HWADDR:                         7C:21:4A:A3:47:C4
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.REASON:                         0 (No reason given)
GENERAL.IP4-CONNECTIVITY:               4 (full)
GENERAL.IP6-CONNECTIVITY:               4 (full)
GENERAL.UDI:                            /sys/devices/pci0000:00/0000:00:14.3/net/wlp0s20f3
GENERAL.IP-IFACE:                       wlp0s20f3
GENERAL.IS-SOFTWARE:                    no
GENERAL.NM-MANAGED:                     yes
GENERAL.AUTOCONNECT:                    yes
GENERAL.FIRMWARE-MISSING:               no
GENERAL.NM-PLUGIN-MISSING:              no
GENERAL.PHYS-PORT-ID:                   --
GENERAL.CONNECTION:                     EasyBox-2EB344 1
GENERAL.CON-UUID:                       8d5d0bb0-11ef-4ee5-943f-701cf9dd78fe
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/20
GENERAL.METERED:                        no (guessed)
-------------------------------------------------------------------------------
WIFI-PROPERTIES.WEP:                    yes
WIFI-PROPERTIES.WPA:                    yes
WIFI-PROPERTIES.WPA2:                   yes
WIFI-PROPERTIES.TKIP:                   yes
WIFI-PROPERTIES.CCMP:                   yes
WIFI-PROPERTIES.AP:                     yes
WIFI-PROPERTIES.ADHOC:                  yes
WIFI-PROPERTIES.2GHZ:                   yes
WIFI-PROPERTIES.5GHZ:                   yes
WIFI-PROPERTIES.MESH:                   no
WIFI-PROPERTIES.IBSS-RSN:               yes
-------------------------------------------------------------------------------

Set wlp0s20f3 method to auto for DHCP (you need remove any static IP if you have one; otherwise you will end up getting both DHCP and static IPs):

nmcli device modify wlp0s20f3  ipv4.method auto
nmcli device modify wlp0s20f3  ipv6.method auto
nmcli device modify wlp0s20f3 connection.autoconnect yes
nmcli networking off
nmcli networking on
nmcli device show wlp0s20f3

Sadly that hasn’t worked.

I got this:

GENERAL.DEVICE:                         wlp0s20f3                                                                                                                                             
GENERAL.TYPE:                           wifi                                                                                                                                                  
GENERAL.HWADDR:                         7C:21:4A:A3:47:C4                                                                                                                                     
GENERAL.MTU:                            1500                                                                                                                                                  
GENERAL.STATE:                          100 (connected)                                                                                                                                       
GENERAL.CONNECTION:                     EasyBox-2EB344 1                                                                                                                                      
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/9                                                                                                    
IP4.ADDRESS[1]:                         10.0.0.66/24                                                                                                                                          
IP4.GATEWAY:                            10.0.0.1                                                                                                                                              
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 10.0.0.1, mt = 600                                                                                                              
IP4.ROUTE[2]:                           dst = 10.0.0.0/24, nh = 0.0.0.0, mt = 600                                                                                                             
IP4.DNS[1]:                             8.8.8.8                                                                                                                                               
IP6.ADDRESS[1]:                         fe80::7e21:4aff:fea3:47c4/64                                                                                                                          
IP6.GATEWAY:                            --                                                                                                                                                    
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 256 

but the problem is not about connecting to the WIFI only (which seems to work in the background always for some reason, cuz I can connect to local server in the network that I have added to hosts file)

the main issue seems to DNS config. For example, after the last set of commands provided I now have to do

resolvectl revert 7
resovelctl rever 8

cuz the 2 connections have this:

GENERAL.DEVICE:                         wlp0s20f3                                                                                                                                             
GENERAL.TYPE:                           wifi                                                                                                                                                  
GENERAL.HWADDR:                         7C:21:4A:A3:47:C4                                                                                                                                     
GENERAL.MTU:                            1500                                                                                                                                                  
GENERAL.STATE:                          100 (connected)                                                                                                                                       
GENERAL.CONNECTION:                     EasyBox-2EB344 1                                                                                                                                      
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/9                                                                                                    
IP4.ADDRESS[1]:                         10.0.0.66/24                                                                                                                                          
IP4.GATEWAY:                            10.0.0.1                                                                                                                                              
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 10.0.0.1, mt = 600                                                                                                              
IP4.ROUTE[2]:                           dst = 10.0.0.0/24, nh = 0.0.0.0, mt = 600                                                                                                             
IP4.DNS[1]:                             8.8.8.8                                                                                                                                               
IP6.ADDRESS[1]:                         fe80::7e21:4aff:fea3:47c4/64                                                                                                                          
IP6.GATEWAY:                            --                                                                                                                                                    
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 256 

and after the resolvectl commands I get this:

Link 8 (pvpnksintrf0)
      Current Scopes: none
DefaultRoute setting: no  
       LLMNR setting: yes 
MulticastDNS setting: no  
  DNSOverTLS setting: no  
      DNSSEC setting: no  
    DNSSEC supported: no  

Link 7 (ipv6leakintrf0)
      Current Scopes: none
DefaultRoute setting: no  
       LLMNR setting: yes 
MulticastDNS setting: no  
  DNSOverTLS setting: no  
      DNSSEC setting: no  
    DNSSEC supported: no

afterwards I stil lhave to do: sudo dhclient w3... to get it all working.

Thanks a lot for the support you are all providing.

Do you have dns=none set anywhere in /etc/NetworkManager/ config file?

sudo grep -Ri 'dns=' /etc/NetworkManager/

Also what does the following command prints? Is is symlink?

 ls -l /etc/resolv.conf

cat /etc/NetworkManager/NetworkManager.conf

delivers this:

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false

[device]
wifi.scan-rand-mac-address=no

ls -l /etc/resolv.conf
delivers this:
lrwxrwxrwx 1 root root 39 abr 4 2022 /etc/resolv.conf → …/run/systemd/resolve/stub-resolv.conf

Contents of resolv.conf are:

# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad

This will tell you more about those DNS issues

systemd-resolve --status

Also the config file is /etc/systemd/resolved.conf

cat /etc/systemd/resolved.conf
sudo nano /etc/systemd/resolved.conf

Set DNS:

[Resolve]
DNS=8.8.4.4 8.8.8.8 2001:4860:4860::8888

Restart it:

sudo systemctl restart systemd-resolved
sudo systemctl status systemd-resolved
systemd-resolve --status
cat /etc/resolv.conf