Ocassionally, Ubuntu might give its users network connection issues. For instance, some users have reported that they experience No Internet Connection issue immediately after installing a fresh Ubuntu 20.04 LTS. This error appears, despite the connection being seemingly active and able to obtain an IP address in Automatic (DHCP) mode. What's more, I have personally experienced this issue on a long-running instance of Ubuntu 20.04 LTS. It happened out of the blue and was probably the result of some updates or being shutdown incorrectly (my hypothesis).
To fix this issue, we shall use Netplan, which is utility included in Ubuntu that can be used to configure network connections via configuration files. More can be read about Netplan HERE.
Run the following command
(base) ➜ ~ sudo nano /etc/netplan/01-network-manager-all.yaml
You should see something like this
# Let NetworkManager manage all devices on this system network: version: 2 renderer: NetworkManager
Essentially, this file tells Netplan to configure all networks. Furthermore, it states that the Network Manager should be used to render these settings down to the level, which is understandable by the OS and hardware. The Network Manager does just what its title says - manages network connections. For instance, by default, it will use the ethernet connection for sending packets. If, however, the user has unplugged the cable, the packets will begin to be sent via a WiFi connection, if one is available. More about the Network Manager can be read HERE.
In our case, we would like to add another configuration file and specify some settings for the ethernet or wireless connection, depending on which one is not working. First, lets get the information about the network adapters on the the machine.
(base) ➜ ~ ip -c a 1: lo: <loopback,up,lower_up> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp8s0: <broadcast,multicast,up,lower_up> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether b8:a1:60:57:05:12 brd ff:ff:ff:ff:ff:ff inet 192.168.1.70/24 brd 192.168.1.255 scope global dynamic noprefixroute enp8s0 valid_lft 83940sec preferred_lft 83940sec inet6 fe80::aaa1:60ff:fe57:522/64 scope link valid_lft forever preferred_lft forever 3: wlp6s0: <broadcast,multicast> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 78:5b:46:2b:6d:f6 brd ff:ff:ff:ff:ff:ff 4: virbr0: <no-carrier,broadcast,multicast,up> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:d4:6d:7c brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 5: virbr0-nic: <broadcast,multicast> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:d4:6d:7c brd ff:ff:ff:ff:ff:ff </broadcast,multicast></no-carrier,broadcast,multicast,up></broadcast,multicast></broadcast,multicast,up,lower_up></loopback,up,lower_up>
On my machine, the ethernet adapter carries the name of
enp8s0 and the wireless adapter carries the name of
Create another file in the same directory, running the following command:
(base) ➜ ~ sudo nano /etc/netplan/01-netcfg.yaml
Add this information into the file (change the network adapter name to that of yours!):
network: version: 2 renderer: networkd ethernets: enp8s0: dhcp4: true
As you can see, we are telling the Netplan to configure our system in a way that the connection for the ethernet adapter with name
enp8s0 should be rendered by networkd. Networkd is part of systemd and can be explored more on THIS page. In essence, we are telling the Netplan to configure this adapter using networkd instead of the Network Manager. It is hard to tell what the exact issue with the Network Manager is, but networkd works better in some cases.
Save the file by pressing Ctrl+X, Y, Enter.
All that is left is to generate an updated configuration using Netplan and then apply it. The following commands will do it.
sudo netplan generate sudo netplan apply
Check your ethernet connection now. It should now have Internet connection. Happy browsing!