7

i am using centos 7. I am typing the command

ip addr show eth0

but its reply Device "eth0" does not exist.

Paulo Tomé
  • 3,754
  • 6
  • 26
  • 38
Dhairya Lakhera
  • 199
  • 1
  • 2
  • 7
  • just try to use autocompletion, maybe the device names differ from one distro to another. Another way is looking in /dev/ and searching for network devices but I think in famous distro it would be ```enp``` – Milad Alkhamis Feb 06 '23 at 06:23
  • @MiladAlkhamis Are you sure that network devices are under `/dev` location? It seems that’s not possible: [Why are network interfaces not in /dev like other devices?](https://unix.stackexchange.com/questions/23199/why-are-network-interfaces-not-in-dev-like-other-devices) and [Is there a device file in the /dev directory that represents the wireless adapter?](https://superuser.com/questions/564113/is-there-a-device-file-in-the-dev-directory-that-represents-the-wireless-adapte) – Edgar Magallon Feb 06 '23 at 22:07
  • Or maybe that has changed over the years, could you give more details about what network devices can be found in `/dev`? I commented again this because the comments have been moved to the question (but I did it to point to your comment and not to the OP) – Edgar Magallon Feb 06 '23 at 22:08

3 Answers3

7

In CentOS, network interfaces are named differently. So they aren't called eth0 or eth1, but rather have names like eno1 or enp2s0. (Source.)

Run ip addr to see how these interfaces are named on your system.

These names are defined in /etc/sysconfig/network-scripts/ifcfg-<iface>. You can change their names if you really wanted to, but I don't recommend it.

dr_
  • 28,763
  • 21
  • 89
  • 133
0

RHEL / CentOS 7.x uses consistent network device naming. And it might also be called predictable network interface names.

in any case the best way I have found to get eth naming back is to

  • yum remove biosdevname
  • edit /etc/default/grub
  • append net.ifnames=0 to GRUB_CMDLINE_LINUX
  • append biosdevname=0 to GRUB_CMDLINE_LINUX if you have biosdevname installed
  • grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg {replace centos with rhel}
  • reboot
  • eth0 and eth1 and so on should now be there instead of the naming syntax that was used.

You do not need to mess with anything under /etc/sysconfig/.

ron
  • 5,749
  • 7
  • 48
  • 84
0

For macOS

@dr's answer applies to macOS too, but on macOS, they're called en0, en1, en2 ....

Running ifconfig in the terminal will list them.

stevec
  • 171
  • 8