3

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
  • 2
    Linux server? Are we talking about "Ubuntu server"? If so, what version is it? – Pizza May 25 '20 at 13:30
  • 1
    Sorry, it's Ubuntu Server, 20.04 LTS i believe. – Daniel H May 25 '20 at 13:44
  • 1
    Edit your question and show me sudo lshw -C network and cat /etc/netplan/*.yaml. Start comments to me with @heynnema or I'll miss them. – heynnema May 25 '20 at 15:07
  • @heynnema I've edited it to show the results from the commands you listed. – Daniel H May 26 '20 at 09:56
  • Thanks for the info, however I need to see the entire output of sudo lshw -C network. Also show me ip a. – heynnema May 26 '20 at 13:07
  • @heynnema I've edited it and shown the entire output of that command, I've also shown the output of ip a – Daniel H May 26 '20 at 14:58
  • Please see my answer. If it's helpful, please remember to accept it by clicking the checkmark icon that appears just to the left of my answer. Thanks! – heynnema May 26 '20 at 15:18

2 Answers2

5

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 generate

sudo netplan apply

reboot # mandatory

link

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

heynnema
  • 70,711
  • @DanielH Glad to hear it! Thanks for the update. – heynnema May 26 '20 at 16:58
  • I was wondering if I could avoid reboot. Thanks for confirming that this was the step I unfortunately needed. – Sridhar Sarnobat Jan 09 '23 at 08:04
  • Note I only had a few lines in my Netplan yaml file (no name servers or addresses) but simply running netplan generate, netplan apply, reboot fixed the broken internet. Thank you! – Jeshua Lacock Oct 10 '23 at 19:06
  • Ubuntu 22.04: "WARNING: gateway4 has been deprecated, use default routes instead" not sure what this means or which documentation its referring to – user5359531 Dec 16 '23 at 15:16
0

To setup a static ip you need to go to /etc/netplan and there you will see a .yaml file. Check the configs there, otherwise if you have a firewall, it might be that it is blocking you.(It is what happened to me)

  • Did you see my answer? And a firewall problem won't cause this. – heynnema May 26 '20 at 15:21
  • yep I did and you are very right, I wanted to add smth about the firewall. – Alion.B May 26 '20 at 15:22
  • As I mention, a firewall problem won't cause this. In this particular case, they had used an incorrect ethernet device ID, and an incorrectly formatted .yaml file. – heynnema May 26 '20 at 15:24