0

I've recently upgraded from 18.04 to 20.04 (on a server, no GUI), and since then the server is not able to connect to the internet, pinging the router and other devices in the lan still works.After checking ip route there's no gateway listed.

After running sudo ip route add default via 192.168.0.1 I do have internet connectivity to download packages, however that doesn't persist across reboots or other sessions.

my /etc/netplan/01-netcfg.yaml looks like this

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      dhcp6: no
      addresses: 
        - 192.168.0.158/24
        - "2a02:1810:8474:9600:21e:6ff:fe30:cf4b/64"
        - "fe80::21e:6ff:fe30:cf4b/64"
      gateway4: 192.168.0.1
      nameservers:
        addresses: 
          - 1.1.1.1
          - 1.0.0.1
          - "2606:4700:4700::1111"
          - "2606:4700:4700::1001"

running ip addr results in this:

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
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:1e:06:30:cf:4b brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.158/24 brd 192.168.0.255 scope global eth0
       valid_lft forever preferred_lft forever

and ip route results in this

192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.158

no "default via {ip}" there, only after running sudo ip route add default via 192.168.0.1 and then it's only there for the current session or until I reboot.

Anyone know how to fix this so my internet connection stays across reboots?

I've checked on google but nothing seems to work, everyone seems to recommend just setting dhcp4 to "true" and removing everything below that, but I need a static IP.

2
  • Is it the only yaml in /etc/netplan directory? netplan apply does not show anything?
    – marosg
    Dec 10, 2020 at 13:23
  • yes it's the only yaml in there netplan apply does not show any errors or anything I ended up fixing it by removing netplan, couldn't figure out for hours what went wrong, just using systemd-network and configuring it there and removing netplan fixed it for me
    – user301538
    Dec 10, 2020 at 19:57

1 Answer 1

0

You probably could have used iptables to fix this, although I don't know the specific command I do know there is a way to do it via iptables and there is also a way to make it persist across reboots. I know because I had setup a vpn quite a while back using a Raspberry Pi and had to set it up like you are talking about, but it has been a long time. I only say "probably" because I don't know the specifics about your setup, so while that worked on a Pi it may not work the same way on your ubuntu server.

Also, I remember it wasn't too difficult but there were a couple of steps and a couple of commands to run to accomplish it. Just in case you wanted to revert back to your netplan format and try it, you will have some general idea of where to start looking for the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.