LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 10-17-2012, 10:09 AM   #1
rocketb
LQ Newbie
 
Registered: Apr 2012
Location: Florida
Distribution: RHEL, CentOS, Fedora
Posts: 15

Rep: Reputation: Disabled
How to get persistent network settings when changing hardware


I have a situation where we spare hard drives for a group of computers. These computers are all basically the same, so the spare hard drives are all from the same image.

The only tricky part is the network settings. The normal way of configuring them is to use the system-config-network utility. The problem is, the configured devices are tied to MAC addresses. When a spare drive is inserted into one of the computers, it sees NICs with different MACs, so creates new devices. In the Network utility, you see that the old devices became eth0.bak, eth1.bak, etc. The new eth0, eth1 then have default configurations.

I would like to be able to put a spare drive in any computer without the end user having to go in and set up all the network settings every time. So does anyone have any suggestions?

The only solution I have come up with is this. I disable the network service. I then add the following lines in /etc/rc.d/rc.local for each NIC:
ifconfig eth0 xxx.xxx.xxx.xxx umask xxx.xxx.xxx.xxx
ifconfig eth0 up
This works because the new devices are always still eth0, eth1, etc. The drawbacks are that unless you know its there, you have no idea how the network is being configured. Also, if an IP address needs to change, a regular user does not have permissions to change it.

Does anyone know a better way to do this?

Running RHEL 5.8 with GNOME.
 
Old 10-17-2012, 11:26 AM   #2
replica9000
Senior Member
 
Registered: Jul 2006
Distribution: Debian Unstable
Posts: 1,130
Blog Entries: 2

Rep: Reputation: 260Reputation: 260Reputation: 260
Not sure if this any help to you.

On my Debian system, udev creates rules for the network cards under /etc/udev/rule.d/70-persistent-net.rules

Code:
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:19.0 (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
So if I were to bring a clone of my HDD to an identical system, udev would see that eth0 is already taken by another MAC, and assign eth1 to the new MAC. So upon boot maybe you could remove the existing rule?
 
Old 10-18-2012, 11:41 AM   #3
rocketb
LQ Newbie
 
Registered: Apr 2012
Location: Florida
Distribution: RHEL, CentOS, Fedora
Posts: 15

Original Poster
Rep: Reputation: Disabled
I'm not sure that will help. It's not so much the device name that is the problem, but the fact that it creates a new device, and that new device then has default settings instead of my configured ones. Essentially, I need it to update the /etc/sysconfig/network-scripts/ifcfg-eth0 file with a new MAC, instead of creating a new file with default settings. Or, maybe if there was a way to alter the default config?
 
Old 10-18-2012, 03:50 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
In /etc/sysconfig/network-scripts/ifcfg-eth0 you must have a line like
Code:
HWADDR=00:00:12:34:56:78
If you can cobble together a script that runs before ifcfg-eth0 is run, then you can modify ifcfg-eth0 to look more like
Code:
. yourMacAddrScript
DEVICE=eth0
BOOTPROTO=dhcp
# HWADDR=00:00:12:34:56:78
ONBOOT=yes
Then, yourMacAddrScript must look like the line assigning the MAC to $HWADDR. Not sure how to find the MAC using a script that must run before the ethernet startup/configuration runs, but ethttool might help. Whatever it is, it just has to generate the one line in yourMacAddrScript. Getting the script to run before the network configuration happens should be simple enough using the standard startup scripting system.

--- rod.

Last edited by theNbomr; 10-18-2012 at 04:16 PM.
 
Old 11-06-2012, 07:18 PM   #5
rocketb
LQ Newbie
 
Registered: Apr 2012
Location: Florida
Distribution: RHEL, CentOS, Fedora
Posts: 15

Original Poster
Rep: Reputation: Disabled
theNbombr, right track, but it's actually easier than that. After tinkering around today, I figured out that the ifcfg-eth0 file doesn't need the HWADDDR= line at all! If you comment it out, then it just works with whatever eth0 is, no matter what eth0's MAC is. I can move the drive to a different computer, and it still works, because it doesn't create a new ifcfg-eth0 file, because it doesn't care what the MAC is!

Taking it a step further, this is can be done from the system-config-network utility as well. On the "Hardware Device" tab for eth0, just uncheck "Bind to MAC Address". (This deletes the HWADDR line from the ifcfg file).

I think this is the "right" way to do it, and is much simpler than I imagined. I just didn't know about it!
 
Old 11-07-2012, 07:48 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
It only works if you have only one NIC. Otherwise the OS will assign device names (eth0, eth1...) arbitrarily.
--- rod.
 
Old 11-07-2012, 07:25 PM   #7
rocketb
LQ Newbie
 
Registered: Apr 2012
Location: Florida
Distribution: RHEL, CentOS, Fedora
Posts: 15

Original Poster
Rep: Reputation: Disabled
I haven't found them to be arbitrary. The hardware I'm working with has 4 ethernet ports. They seem to always be eth0 to eth3, in physical order, on each machine.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing network settings in Slack 12.1 shivkiyer Slackware 5 09-09-2010 11:42 PM
Simple - Changing your network settings without rebooting??? Exio Linux - Newbie 10 12-02-2006 11:14 AM
Changing a hardware modem IO and IRQ settings. xode Linux - Software 2 09-28-2005 09:31 PM
Changing Network Settings ComputerErik Slackware 1 08-06-2005 12:21 AM
Changing DHCP Network Settings dhammika Linux - Networking 3 03-16-2004 08:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 12:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration