[CentOS] Back to eth shuffling ...

Thu May 14 17:51:17 UTC 2015
Ashley M. Kirchner <ashley at pcraft.com>

When I was working on this last time (with the r8169 driver), someone on
this list provided the following script which is what "fixed" the issue at
the time by creating a new 70-persistent-net.rules file with the devices
enumerated in order. However, this no longer works now.

echo "[KICKSTART] Binding eth interfaces to the expected MAC address in
echo "## Created by Kickstart to keep network interfaces in an expected
order" > \
echo "" >> \

cd /sys/class/net/
for NETDEV in $(ls | /bin/grep eth | sort)
    ## Create a UDEV rule for each eth interface
    echo "## ${NETDEV} interface" >> \

    ## We throw this one in here as it can contain some useful information
    echo "## $(dmesg | /bin/grep ${NETDEV} | /bin/grep -i -v -e "console"
-e "Command line" | head -1)" >> \

    echo -n "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", " >> \
    echo -n "ATTR{address}==\"$(cat ${NETDEV}/address)\", " >> \
    echo -n "ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth?*\", "
>> \
    echo -e "NAME=\"${NETDEV}\"\n" >> \

    ## Make a log of the devices present during install
    echo -e "${NETDEV} $(cat ${NETDEV}/address)\n" >>  /root/ksnet-devices

    ## Also remove the HWADDR line from all of the net config files
    /bin/grep -v -e NAME -e HWADDR -e NM_CONTROLLED \
        /etc/sysconfig/network-scripts/ifcfg-${NETDEV} | sed 's/\"//g' \
        > /etc/sysconfig/network-scripts/ifcfg-${NETDEV}-tmp
    echo "NM_CONTROLLED=no" >>
    #/usr/bin/perl -p -i -e 's/dhcp/none/'
    /bin/mv -f /etc/sysconfig/network-scripts/ifcfg-${NETDEV}-tmp \

After the machine boots and I look in /root/ksnet-devices, I see the MAC
addresses for the devices as:
Port1 -> eth0
PCIe Card-> eth1
Port2 -> eth2

And yet, during the machine's POST (which  can verify by the PXE boot up of
each device), it correctly enumerates the ethernet devices as:
PCIe card

So where and why is the order changed when the kernel kicks in and start
booting the machine? And how can I stop it, or change its behavior? I'm not
seeing any 'renaming' going on in dmesg like I sometimes find. So something
is causing this and I can't figure it out.

On Wed, May 13, 2015 at 5:17 PM, Kahlil Hodgson <
kahlil.hodgson at dealmax.com.au> wrote:

> Have you tried having kickstart set up a more appropriate
> /etc/udev/rules/70-persistent-net.rules?
> This is normally written by /lib/udev/write_net_rules.  You should be able
> to modify the automatically generated one to match what you need.
> K
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos