Ubuntu – Linux Ubuntu Server 20.04 LTS: ‘Network Unreachable’

internetnetworking

I honestly don't have a clue what the issue is as i'm fairly new to Linux and networking. It was working fine for the past month but now it just doesn't want to connect to the internet at all. I've tried to ping my router, 192.168.1.254 and 8.8.8.8 but they both say network unreachable.
I tried looking in sudo nano /etc/network/interfaces, but it is just a blank file with nothing in it. Any help is appreciated, thanks.

*-network = DISABLED
description: Ethernet Interface
product: PCI Express Gigabit Ethernet Controller
vendor: Realtek Semiconductor Ltd
physical id: 0
bus info: pci@0000:04:00.0
version: 06
serial: c8:60:00:9e:bf:d1
width: 64 bits
clock: 33mhz
capabilities: pm msi pciexpress msix vpd bus_master cap_list 
ethernet_physical
configuration: broadcast=yes driver=r8169 latency=0 link=no multicast=yes
resources: irq:18 ioport:d000(size=256) memory: f0304000-f0304fff memory: 
f0300000-f0303fff

that's what comes out when I type in 'sudo lshw -C network'

This is from cat /etc/netplan/*.yaml

network:
  ethernets:
   enp7s0:
    addresses:
    - 192.168.1.200/24
    gateway4: 192.168.1.254
    nameservers:
       addresses:
       -8.8.8.8
       -8.8.4.4
   version: 2

Here is what comes out with 'ip a'

1: io: <LOOPBACK.UP.LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN grou 
       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: enp4s0: <BROADCAST.MULTICAST> mtu 1500 qdisc noop state DOWN group default 
           qlen 1000
            link/ether c8:60:00:9e:bf:d1 brd ff:ff:ff:ff:ff:ff

Best Answer

You may have two problems.

.yaml file

Replace your /etc/netplan/*.yaml with my .yaml code. Keep the exact spacing, indentation, and no tabs.

sudo -H gedit /etc/netplan/*.yaml # replace the * with the correct filename

network:
  version: 2
  renderer: networkd
  ethernets:
    enp4s0:
      addresses:
        - 192.168.1.200/24
      gateway4: 192.168.1.254
      nameservers:
        addresses:
          - 8.8.8.8
          - 8.8.4.4

Then do:

sudo netplan --debug generate

sudo netplan apply

reboot # mandatory

link

"link=no" indicates that an ethernet cable may not be attached.

Related Question