Generating ifcfg-eth0 from scratch

Rick Stevens ricks at nerd.com
Sat May 14 01:21:57 UTC 2011


On 05/13/2011 05:03 PM, Alex wrote:
> Hi,
> 
> On Wed, May 11, 2011 at 10:45 AM, JB <jb.1234abcd at gmail.com> wrote:
>> The results of scan for UUID:
>>
>> # grep -ir uuid /etc/init.d/
>> /etc/init.d/messagebus:        /bin/dbus-uuidgen --ensure
>>
>> The above relates to machine-id.
>>
>> # grep -ir uuid /etc/sysconfig/
>> /etc/sysconfig/network-scripts/ifup:if [ "$USE_NM" = "true" -a -n "$UUID" ];
>>  then
>> /etc/sysconfig/network-scripts/ifup:    nmcli con up uuid "$UUID"
>> /etc/sysconfig/network-scripts/ifdown:    if [ -n "$UUID" -a -z "$DEVICE" ];
>> then
>> /etc/sysconfig/network-scripts/ifdown:  DEVICE=$(nmcli -t --fields uuid,devices
>> con status | awk -F ':' "\$1 == \"$UUID\" { print \$2 }")
>> /etc/sysconfig/network-scripts/network-functions:get_uuid_by_config ()
>> /etc/sysconfig/network-scripts/network-functions:    if [ -z "$UUID" -a
>> "$USE_NM" = "true" ]; then
>> /etc/sysconfig/network-scripts/network-functions:
>> UUID=$(get_uuid_by_config $CONFIG)
> [snip..]
> 
> Yes, it does appear that much of that file is for the purpose of
> NetworkManager, which I'm not using. I was just concerned about the
> interfaces somehow getting switched, such as from a kernel upgrade or
> some kind of module loading race.
> 
> In any case, thanks for your help, as always. It appears to be
> reliable now, but I'll continue to search for possible ways to
> permanently bind an IP to an interface without using NetworkManager.

If you're not using NM, then all you really need in an ifcfg-ethX file
is:

	DEVICE=ethX
	HWADDR=xx:xx:xx:xx:xx:xx
	BOOTPROTO=static
	IPADDR=xxx.xxx.xxx.xxx
	NETMASK=xxx.xxx.xxx.xxx
	DNS1=xxx.xxx.xxx.xxx
	DNS2=xxx.xxx.xxx.xxx
	ONBOOT=yes
	NM_CONTROLLED=no

The HWADDR thing will tie the config to a specific NIC and bypasses
what the kernel determines is ethX.  The DNS stuff is optional as well,
and simply gets stuffed into your /etc/resolv.conf file (if it's empty).

You can also specify "GATEWAY=" to specify the gateway for the machine,
although normally that's in the /etc/sysconfig/network file.

This should work whether or not NM is running.  The "NM_CONTROLLED=no"
stuff SHOULD tell NM to "keep yer mitts off this!"  If you really never
use NM (e.g. the machine is a server), then you should also:

	chkconfig NetworkManager off
	chkconfig network on

This should prevent NM from starting on the next reboot and use the
good old normal networking scripts.

Now, if we could just get the NM people to write a bloody manual, we'd
be SO much better off.  I've offered to do it and was greeted by a stony
silence at their end.
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer, C2 Hosting          ricks at nerd.com -
- AIM/Skype: therps2        ICQ: 22643734            Yahoo: origrps2 -
-                                                                    -
-         Microsoft Windows:  Proof that P.T. Barnum was right       -
----------------------------------------------------------------------


More information about the users mailing list