I am creating an RHEL6 OS disk image that will potentially be passed around to many different computers with identical hardware (except for serial numbers such as MACs). The image is pre-configured and is copied after the system is setup. (So no firstboot etc.) Once the image is placed on a HDD that HDD may be place in multiple different computers.

I want all networking interfaces created to be named eth0 regardless of the MAC. I have removed/modified the persistent-net udev rules to ensure that the single network interface available is named eth0. (With the persistent-net udev rule the eth* would keep counting as the drive got passed between computers.) As such this is working.

Problem Statement:

I also want all these computers to use a static IP address. I need the IP address to be assigned even if there isn't a valid network connected to the computer. I have modified the ifcfg-eth0 to set the IP address but this is MAC dependent so it doesn't work when I move the disk to another computer. (The NetworkManager is also MAC dependent as far as I can tell.)

If the ifcfg-eth0 file doesn't have the HWADDR line then it works fine when moved between computers. I added a RUN command to the end of my udev rule to run a script which would remove the HWADDR line from ifcfg-eth0 but that doesn't work because I'm pretty sure the file system is mounted read-only during udev so it can't actually modify ifcfg-eth0.

I want the single network interface on the computer to come up at boot with an IP address that is pre-specified no matter what the current MAC is. I think I am really close but I just can't seem to come up with the final bits to force it to assign the IP address to whatever interface is available.




If the HWADDR line matches the MAC in the computer at the time it is fine. But if the HWADDR line does not match the kernel complains at boot-up saying:

Bringing up interface eth0:  Device eth0 has different MAC address than expected, ignoring.   [FAILED]

If the HWADDR line isn't present at boot it works fine but it populates that line automatically at some point so the next time you move the drive around it won't work. I thought of just using sed and removing the HWADDR line at boot up during udev but because of the read-only filesystem I don't think that is actually a good idea (or would work).

  • Is this a single disk image, so there will be only one hard drive with this image? Can you post your ifcfg-eth0 into the question. – becomingwisest Jan 18 '13 at 16:25
  • It is a single disk image but that image will be transferred to multiple hard drives. These drives are then be shared among multiple computers. The drives can get all mixed up between computers. – moderj Jan 18 '13 at 17:06

Set the immutable bit on the file so that it cannot be modified (without removing the bit):

chattr +i /etc/sysconfig/network-scripts/ifcfg-eth0

  • Thanks that worked great! I should have thought of that. – moderj Jan 22 '13 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.