Skip to content

Instantly share code, notes, and snippets.

@luco
Forked from pandamoon21/fix_do_droplet_internet.md
Created August 28, 2024 14:01
Show Gist options
  • Save luco/7aff589dc9270fcc383023da2908638a to your computer and use it in GitHub Desktop.
Save luco/7aff589dc9270fcc383023da2908638a to your computer and use it in GitHub Desktop.
Fix Digital Ocean droplet error no connection

From here with modifications, https://www.digitalocean.com/community/questions/no-internet-connection-after-droplet-reboot

  1. Open DO droplet control panel, open networking, save publicipv4, gateway, netmask
  2. Open Access in control panel, open recovery console
  3. Check active network adapter with this command
ip link ls up

if eth0/eth1 not showing, continue

  1. Get mac address in here
/etc/netplan/50-cloud-init.yaml
  1. Create file "/etc/udev/rules.d/70-persistent-net.rules" and add this if not available, edit it to match your mac address
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="please_enter_your_mac_address", NAME="eth0"

example:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="22:28:20:7d:b8:f2", NAME="eth0"
  1. Assign your ip and netmask and activate the device
sudo ifconfig eth0 {your_publicip} netmask {your_netmask} up

example:
sudo ifconfig eth0 207.154.193.4 netmask 255.255.240.0 up

or if ifconfig is not available use

ip a add {your_publicip}/{your_netmask} dev eth0
ip link set dev eth0 up

example:
ip a add 207.154.193.4/255.255.240.0 dev eth0
ip link set dev eth0 up
  1. Set gateway
ip route add default via {your_gateway}

example:
ip route add default via 207.154.192.1
  1. Change dns resolver, edit nameserver value in this file to 1.1.1.1 or 8.8.8.8 or another dns
sudo nano /etc/resolv.conf
  1. Install cloud-init
sudo apt update
sudo apt upgrade
sudo apt install cloud-init

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

  1. [Optional] Install landscape-sysinfo command which is used to show server information on your welcome screen when you connect to your server.
sudo apt install ufw
sudo apt install landscape-common

Last edit: 28-09-2022

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