1

I have followed a youtube video on creating an ec2 and then adding two elastic ip addresses to the instance. However when I ssh into the ubuntu server to add the new secondary ip I get an error that says

cannot find device "eth0"

when I run the below command

sudo ip addr add 172.31.32.210/20 dev eth0

Note I released that ip so its not my ip address anymore but you can see the command I am using. What would cause this error and how to resolve?

If I run a ip link command I get the below:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 0e:e4:6d:b4:d6:93 brd ff:ff:ff:ff:ff:ff
Jayreis
  • 145
  • 15

1 Answers1

2

The problem is that your network interface is named ens5, not eth0. You should use the correct interface name in your commands. Having interfaces actually named eth0 after the system is booted has been deprecated for years, and these days you should treat it as an example only, especially when using outdated tutorials.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • Thank you !! So I should do a ip link anytime I setup an ec2 to get what the network interface is labeled as. I think in the ec2 console when creating an instance the network interface section lists ent0 in the default row. – Jayreis Aug 19 '20 at 03:33
  • 1
    The device name _should_ always be the same for any particular combination of Linux distro and EC2 instance type (e.g. Ubuntu 18.04 LTS on t2.medium). But checking it is always a good idea. – Michael Hampton Aug 19 '20 at 03:53