Sometimes, software or operating system updates accidentally rename a Droplet’s network interface. This causes the Droplet to lose network connectivity because DigitalOcean’s network expects Droplet interfaces to have specific names (eth0
and eth1
) in order to correctly route traffic. Correcting a Droplet’s interface names can restore its connectivity.
To check your Droplet’s network interface names, log in to your Droplet using the Droplet recovery console and then use the ip addr
command:
ip addr
The command returns output that looks like 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
inet6 ::1/128 scope host
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 fa:a8:50:5d:2f:80 brd ff:ff:ff:ff:ff:ff
altname enp0s3
altname ens3
inet 137.184.168.241/20 brd 137.184.175.255 scope global eth0
valid_lft forever preferred_lft forever
inet 10.20.0.8/16 brd 10.20.255.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::f8a8:50ff:fe5d:2f80/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 2e:1a:1d:53:3f:e0 brd ff:ff:ff:ff:ff:ff
altname enp0s4
altname ens4
inet 10.118.0.5/20 brd 10.118.15.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::2c1a:1dff:fe53:3fe0/64 scope link
valid_lft forever preferred_lft forever
This example shows information about the Droplet’s three network interfaces named lo
, eth0
, and eth1
. Each interface has a specific purpose:
lo
is the Linux loopback interface which allows network applications to communicate with themselves over the network. This interface’s name is unlikely to change and is not the focus of this article.eth0
is the Droplet’s primary network interface that manages all traffic between the Droplet and the public internet, including HTTP requests and SSH connections. The address of the Droplet’s eth0
interface is the Droplet’s public IP address.eth1
manages the Droplet’s connection to its virtual private cloud (VPC) network. This allows the Droplet to communicate with other DigitalOcean resources in the same VPC network as the Droplet without having to connect to the public internet. The address of the Droplet’s eth1
interface is the Droplet’s private IP address.If the Droplet’s public and private network interfaces are named anything other than eth0
and eth1
, you need to correct the names for the Droplet to reconnect to DigitalOcean’s network. If the names are already correct but you’re still experiencing connection issues, try debugging the Droplet’s network configuration.
To correct any network interface names, you need to update the Droplet’s network configuration in the /etc/netplan/50-cloud-init.yaml
file. To do this, open the cloud-config file using nano
or another text editor:
nano /etc/netplan/50-cloud-init.yaml
The file looks like the following example. The interface names in this example are intentionally incorrect to demonstrate how to fix them.
network:
version: 2
ethernets:
enp0s25:
addresses:
- 198.51.100.24/20
- 192.0.2.126/16
match:
macaddress: c6:5d:fe:b1:32:23
mtu: 1500
nameservers:
addresses:
- 67.207.67.2
- 67.207.67.3
search: []
routes:
- to: 0.0.0.0/0
via: 167.99.176.1
set-name: enp0s25
enp6s0:
addresses:
- 203.0.113.85/20
match:
macaddress: 82:d1:60:77:2f:3a
mtu: 1500
nameservers:
addresses:
- 67.207.67.2
- 67.207.67.3
search: []
set-name: enp6s0
In the file, there are two objects beneath the ethernets
field that represent the Droplet’s public and private network interface configurations which have the incorrect keys of enp0s25
and enp6s0
. Edit the top-level key of each network interface to their correct names, eth0
and eth1
. Use eth0
for the interface with the Droplet’s public IP address and eth1
for the interface with the Droplet’s private IP address. You can find the Droplet’s IP addresses on its overview page in the control panel.
Next, set the set-name
value of each object to their respective interface names.
The result should look like this:
network:
version: 2
ethernets:
eth0:
addresses:
- 198.51.100.24/20
- 192.0.2.126/16
match:
macaddress: c6:5d:fe:b1:32:23
mtu: 1500
nameservers:
addresses:
- 67.207.67.2
- 67.207.67.3
search: []
routes:
- to: 0.0.0.0/0
via: 167.99.176.1
set-name: eth0
eth1:
addresses:
- 203.0.113.85/20
match:
macaddress: 82:d1:60:77:2f:3a
mtu: 1500
nameservers:
addresses:
- 67.207.67.2
- 67.207.67.3
search: []
set-name: eth1
When you finish the edits, save and close the file.
To test the new configuration, run the netplan
trial command. This temporarily applies the new network configuration for 120 seconds:
netplan try --debug
In a separate terminal window, use ping
to test if the Droplet is accessible via the public internet from your local machine:
ping <your-droplets-public-IP-address>
If ping
returns output that looks like this, your Droplet is connected to the internet:
64 bytes from 198.51.100.24: icmp_seq=0 ttl=53 time=39.051 ms
64 bytes from 198.51.100.24: icmp_seq=1 ttl=53 time=36.596 ms
64 bytes from 198.51.100.24: icmp_seq=2 ttl=53 time=32.858 ms
64 bytes from 198.51.100.24: icmp_seq=3 ttl=53 time=32.796 ms
Press Ctrl+C
to exit the ping
diagnostic.
Back in the recovery console, press ENTER to accept the network configuration changes.