DEV Community

adhham
adhham

Posted on

How to Fix No Internet Connection in Digital Ocean's Droplet

Digital Ocean stores its network configuration in two interfaces: eth0 and eth1.

  • eth0 is used for public network (aka. The Internet)
  • eth1 is used for internal private network (ie. digital ocean's internal network)

The correct naming of these interfaces is a must for it to work properly; it should have the exact same name.

In your droplet, run ip -br a command to see if these two interfaces are correctly configured. If you see an output like this, it means the interfaces are not up.

$ ip -br a
eth0 DOWN
eth1 DOWN
Enter fullscreen mode Exit fullscreen mode

To follow this tutorial you will need the public IP address and router gateway IP of your droplet. The public IP can be found in your droplet's dashboard page. If you don't know your gateway IP address, I recommend lodging a support ticket.

To configure eth0 or public network interface, run the following commands:

$ ip addr add 123.456.78.9/20 dev eth0
$ ip link set eth0 up
$ ip route add default via 123.456.0.1
Enter fullscreen mode Exit fullscreen mode

Replace 123.456.78.9/20 with your droplet's public IP address and 123.456.0.1 with the gateway IP address.

Now, configure the nameservers. Edit /etc/resolv.conf file and add the following nameservers:

nameserver 8.8.8.8
nameserver 8.8.4.4
Enter fullscreen mode Exit fullscreen mode

Apply the netplan configurations to make these changes persistent:

$ sudo netplan --debug generate
$ sudo netplan --debug apply
Enter fullscreen mode Exit fullscreen mode

Run the ip -br a command again. If it gives a similar output to the one shown below, it means the interface has been configured.

$ ip -br a
eth0 UP 123.456.78.9/20
Enter fullscreen mode Exit fullscreen mode

You can test this by pinging to a website. Try ping google.com and see if it is working correctly.

Top comments (0)