From here with modifications, https://www.digitalocean.com/community/questions/no-internet-connection-after-droplet-reboot
- Open DO droplet control panel, open networking, save publicipv4, gateway, netmask
- Open Access in control panel, open recovery console
- Check active network adapter with this command
ip link ls up
if eth0/eth1 not showing, continue
- Get mac address in here
/etc/netplan/50-cloud-init.yaml
- 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"
- 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
- Set gateway
ip route add default via {your_gateway}
example:
ip route add default via 207.154.192.1
- Change dns resolver, edit nameserver value in this file to
1.1.1.1
or8.8.8.8
or another dns
sudo nano /etc/resolv.conf
- 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.
- [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
Life saver! Thanks a lot!