0

On a dell pc, the only ethernet interface off the motherboard shows up as em1.

On a newer supermicro server, the interface names are enp137s0f0

On some older supermicro servers, they are eth0..eth3

In setting up a firewall (RHEL/Centos 7) I need to create a zone and bind it with the correct interface name: eth0, em1, enp137s0f0.

In writing a script what is the best way on any given hardware, with the OS being RHEL/CentOS 7, to get the active interface name?

Why do they vary? Is there a way to make everything just eth0..eth# ?

I need to do firewall-cmd --permanent --zone=mycustomezone --change-interface=???

ron
  • 6,575
  • 3
    This is two questions in one. The first has already been asked and answered several years ago at https://unix.stackexchange.com/q/134483/5132 . – JdeBP May 21 '19 at 16:31
  • 1
    There could be multiple active interfaces. If you look at the interfaces listed in ip link, is there one that you could programmatically choose? Would it be the first one after lo0? Would it be the one shown in ip route show default or ip route get 8.8.8.8? – Mark Plotnick May 21 '19 at 16:50
  • 1
    One quick way to revert back to the old eth0 style of interface names on some systems is to modify the boot loader commands with net.ifnames=0 biosdevname=0 – Jason K Lai May 21 '19 at 17:17

0 Answers0