Centos 7 and multiple network cards

Issues related to configuring your network
Post Reply
tuxtux
Posts: 3
Joined: 2015/11/09 23:31:04

Centos 7 and multiple network cards

Post by tuxtux » 2015/11/10 02:59:03

My first post here:-)

Just spent the best part of 2 days trying to get Centos7 to rename network interfaces and failed to get it going.

Some suggestions posted here did not work. Many variations and "solutions" from Google searches did not
work and extensive reading of RHEL 7 Network documents has not got me any closer to a solution.

Install: Minimal.
NetworkManager: Disabled as per numerous instructions everywhere.
This includes doing the Grub line 'net.ifnames=0' and 'biosdevname=0'
Machine has 4 network cards, 2 on-board and 2 PCI network cards, all Intel based.

Desired outcome:

Get the 4 network cards to have specific names as per traditional "old style" scripts.

The names should be the old style eth0, eth1, eth2 and eth3 with configuration
stored in 'ifcfg-ethx' format files.

Using 'ifconfig -a' always shows eth0 and eth1 being the on-board network interfaces
while eth2 and eth3 are the 2 PCI network cards.

I want to use the network interfaces MAC addresses to determine the name of the interface
and have tried 70-persistent-net.rules, 60-net.rules, MAC address (HWADDR) in ifcfg-ethx
files and a few other things in various combinations.

I can always set DEVICE and NAME in the ifcfg-ethx file and get it to go OK for 1 interface
by having the DEVICE and NAME entries set to eth2 which matches eth2 from the 'ifconfig -a'
command.

I want the 2 PCI network cards to be named eth0 and eth1. The 2 on-board network interfaces
should be eth2 and eth3.

This may have been thrashed to death before but I have all but given up and think that CentOS7
does not support renaming interfaces although documentation out there says it can.

Any assistance with this specific problem would be much appreciated.

tuxtux
Posts: 3
Joined: 2015/11/09 23:31:04

Re: Centos 7 and multiple network cards

Post by tuxtux » 2015/11/10 21:58:25

Just some additional information, my "/etc/udev/rules.d/70-persistent-net.rules"

I have used a descriptive name instead of the MAC address and inserted it to make it easier to see the different locations in the files.

SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="<MAC addr PCI if card 1>",ATTR{dev_id}=="0x0",ATTR{type}=="1",KERNEL=="eth*",NAME="eth0"
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="<MAC addr PCI if card 2>",ATTR{dev_id}=="0x0",ATTR{type}=="1",KERNEL=="eth*",NAME="eth1"
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="<MAC addr on-board if 1>",ATTR{dev_id}=="0x0",ATTR{type}=="1",KERNEL=="eth*",NAME="eth2"
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="<MAC addr on-board if 2>",ATTR{dev_id}=="0x0",ATTR{type}=="1",KERNEL=="eth*",NAME="eth3"

Here are the "ifcfg-ethx" files

"/etc/sysconfig/network-scripts/ifcfg-eth0"

HWADDR="<MAC addr PCI if card 1>"
DEVICE="eth0"
NM_CONTROLLED="no"
ONBOOT="yes"
BOOTPROTO=static
NAME="eth0"
IPADDR=192.168.1.239
NETMASK=255.255.255.0



"/etc/sysconfig/network-scripts/ifcfg-eth1"

HWADDR="<MAC addr PCI if card 2>"
DEVICE="eth1"
NM_CONTROLLED="no"
ONBOOT="yes"
BOOTPROTO=static
NAME="eth1"
IPADDR=192.168.2.239
NETMASK=255.255.255.0



"/etc/sysconfig/network-scripts/ifcfg-eth2"

HWADDR="<MAC addr on-board if 1>"
DEVICE="eth2"
NM_CONTROLLED="no"
ONBOOT="yes"
BOOTPROTO=static
NAME="eth2"
IPADDR=192.168.3.239
NETMASK=255.255.255.0



"/etc/sysconfig/network-scripts/ifcfg-eth3"

HWADDR="<MAC addr on-board if 2>"
DEVICE="eth3"
NM_CONTROLLED="no"
ONBOOT="yes"
BOOTPROTO=static
NAME="eth3"
IPADDR=192.168.4.239
NETMASK=255.255.255.0


Here is the output from "ifconfig -a" before any changes.

eth0: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether <MAC addr on-board if 1> txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xfe9c0000-fe9e0000

eth1: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether <MAC addr on-board if 2> txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0xfeae0000-feb00000

eth2: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether <MAC addr PCI if card 1> txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eth3: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether <MAC addr PCI if card 2> txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0



And output from "ip addr"
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
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> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether <MAC addr on-board if 1> brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether <MAC addr on-board if 2> brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether <MAC addr PCI if card 1> brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether <MAC addr PCI if card 2> brd ff:ff:ff:ff:ff:ff

tuxtux
Posts: 3
Joined: 2015/11/09 23:31:04

Re: Centos 7 and multiple network cards

Post by tuxtux » 2015/11/11 03:18:05

Again, I am replying to my own post:-))

I have been bitten by the following issue:

https://bugs.centos.org/view.php?id=7591

From what I gather, Redhat made the change deliberately and they do not consider it a bug. Therefore
CentOS do not consider it a bug as it is upstream and they will not change it. I can live with the interface
numbers being higher, not sure about others.

Solution for me was to use interface names/numbers above the 4 first ones (eth0, eth1, eth2 and eth3)

So instead of using low numbers I did this:

SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="<MAC addr PCI if card 1>",ATTR{type}=="1",KERNEL=="eth*",NAME="eth10"
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="<MAC addr PCI if card 2>",ATTR{type}=="1",KERNEL=="eth*",NAME="eth11"
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="<MAC addr on-board if 1>",ATTR{type}=="1",KERNEL=="eth*",NAME="eth12"
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="<MAC addr on-board if 2>",ATTR{type}=="1",KERNEL=="eth*",NAME="eth13"

This seems to work correctly and is persistent across reboots.

Before the results kept changing and it was very confusing.

This stuff is not documented in any of the Redhat or Centos documents (Not that I could find).

If anyone has any additional info please post, otherwise this thread is done.

masterhaos
Posts: 1
Joined: 2016/01/28 11:12:46

Re: Centos 7 and multiple network cards

Post by masterhaos » 2016/01/28 12:02:01

For me, renaming the NICs, like eth10, eth11, eth12 or eth13, wasn't an option, so i found different solution for this issue.
First solution I've done the steps you described before
- Install: Minimal
- NetworkManager: Disabled
- in Grub 'net.ifnames=0' and 'biosdevname=0'
- /etc/udev/rules.d/70-persistent-net.rules with desired addressing[/quote]
and then after startup i've reinstall the drivers for the network cards. This way the desired naming was preserved.

The script that will do that:

Code: Select all

#!/bin/bash

drivers=`dmesg |grep "Ethernet"|grep "Driver"|awk '{print $3}'|grep ":"|awk -F':' '{print $1}'|sort|uniq`
service network stop
for driver in $drivers 
do
  rmmod $driver
done

for driver in $drivers 
do
  modprobe $driver
done

service network start
Second solution was in fact the realization that the problem was the line from Grub 'net.ifnames=0' and 'biosdevname=0'.
If you start the OS with 'net.ifnames=0' and 'biosdevname=0', then the udev names, randomly i think, the interfaces with eth0, eth1, etc. and when is trying to apply the renaming rules from /etc/udev/rules.d/70-persistent-net.rules, for example from existing eth0 to eth1, eth1 already exists and the rule is skipped.
Without 'net.ifnames=0' and 'biosdevname=0' then the udev names, the interfaces with the new en* style and the rules from /etc/udev/rules.d/70-persistent-net.rules are applied without problem. At least it worked in my case.

Post Reply