Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Background:

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.

EDIT:

ifcfg-eth0:

DEVICE=eth0
IPADDR=10.10.10.10
BROADCAST=10.10.10.255
ONBOOT=yes
NAME=eth0
BOOTPROTO=none
NETMASK=255.255.255.0
TYPE=Ethernet
HWADDR=##:##:##:##:##:##
IPV6INIT=no
USERCTL=no
NM_CONTROLLED=no

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).

share|improve this question
    
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

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
    
Thanks that worked great! I should have thought of that. –  moderj Jan 22 '13 at 13:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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