Skip to content

Instantly share code, notes, and snippets.

@paulozullu
Last active August 15, 2023 20:50
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulozullu/6ec21cf18a1e5354a423e43690dbd02c to your computer and use it in GitHub Desktop.
Save paulozullu/6ec21cf18a1e5354a423e43690dbd02c to your computer and use it in GitHub Desktop.
DigitalOcean without internet

After almost two weeks since I raised this issue, I was finally able to resolve it. The problem occurred in the first place because different packages got uninstalled somehow when I rebooted. This includes cloud-init, ufw and landscape-common. There is probably more that I haven’t noticed yet. Let’s start with the internet connection, this is how I fixed it:

  • Step 1. I created file “/etc/udev/rules.d/70-persistent-net.rules” and added
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="b2:fe:09:35:6e:57", NAME="eth0"

as I mentioned previously. Note that MAC address used above can be found here: “/etc/netplan/50-cloud-init.yaml”

  • Step 2. Run “sudo reboot” and check that eth0 interface persists by running “ifconfig -a”

  • Step 3. Run the following command:

sudo ifconfig eth0 207.154.193.4 netmask 255.255.240.0 up

Your IP address and netmask can be found if you go to your Droplet’s page and then go to Networking tab. It is important that both these are correct.

  • Step 4. Run another command:
ip route add default via 207.154.192.1

This is your gateway address which again can be found on Networking tab on your Droplet’s page. At this point you should be able to access your server through SSH. If you try to run “ping www.google.com” it will fail to resolve the domain. Also if you do “sudo reboot”, the configuration won’t persist and you will need to repeat steps 3-4 again. So let’s continue.

  • Step 5. Run command:
sudo nano /etc/resolv.conf

and change nameserver to “8.8.8.8”, i.e. Google’s DNS, and save the file. Now you should be able to run “ping www.google.com” and receive response.

  • Step 6. Now I ran these:
sudo apt update
sudo apt upgrade

not sure if this was necessary though.

  • Step 7. Let’s install the missing cloud-init so that network configuration persists next time we reboot. We can do this by running:
sudo apt install cloud-init

Now you should be able to run “sudo reboot” without losing network connection.

  • Step 8. Finally, I installed some missing packages by running these:
sudo apt install ufw
sudo apt install landscape-common

landscape-common will enable “landscape-sysinfo” command which is used to show server information on your welcome screen when you connect to your server.

There is probably more stuff that is missing and my Droplet is not exactly the same as it was when I first created it but at least I was able to restore network connection, missing packages that I use and continue running my scripts are before. I hope this hasn’t left any security hole in my system. Probably it would be wise to create new Droplet from scratch at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment