[CLUG] network card id switching

Tomasz Ciolek tmc at vandradlabs.com.au
Mon Jun 12 03:16:44 GMT 2006


Hi All

Actually, the bets way I found, is to have NICS from different makes
and bind them to interfaces by module aliases. this way the order of the
kernel modules loading on boot (as stet up by you) determines which is
eth0, eth1, etc... 

Hope that makese sense.

Tomasz

On Mon, Jun 12, 2006 at 10:56:58AM +1000, Tony Breeds wrote:
> On Fri, Jun 09, 2006 at 05:50:08PM +1000, freegazer wrote:
> > I will soon need to do a bit of work on some dual nic'd machines. I remember
> > during the recent presentation on diskless booting that there was more than
> > a little discussion on the problem of nic addresses changing at boot time.
> > If memory serves right Bob mentioned that he resolved the issue be changing
> > the default boot sequence for Debian so that the cards would keep the same
> > "eth" location.
> > Does anyone know of an article on this? Or perhaps is there a chance sombody
> > kept reasonable notes?
> > The systems need to be running RH rather than Debian so I don't know if
> > exactly the same fix will work but I would like to look into it.
> 
> Debian has a couple of nice ways to do this but you say you need Redhat
> so we'll ignore them
> 
> The quickest way to do it I can think of is write a init.d script that
> runs before the network is brought up.
> 
> something like: (completely untested)
> ---
> #!/bin/bash
> 
> # Hmm what if /usr isn't available?
> NR_ETH=$(/bin/ip link | /bin/egrep eth.: | /usr/bin/wc -l )
> 
> # Rename all interfaces to avoid conflicts
> for i in $( /usr/bin/seq 0 $(( ${NR_ETH} - 1 )) ; do
> 	/bin/ip link set eth${i} name eth${i}_
> done
> 
> for i in $( /usr/bin/seq 0 $(( ${NR_ETH} - 1 )) ; do
> 	MAC=$( /bin/ip ip link show dev eth${i}_ | \
> 		/bin/egrep link | /usr/bin/awk '{print $2}' | \
> 		/usr/bin/tr A-Z a-z )
> 
> 	# This could be a shell style glob
> 	case "${MAC}" in
> 	02:06:1b:03:29:06:c9:da)
> 		/bin/ip link set eth${i}_ name eth1
> 		;;
> 	00:06:1b:03:29:06:c9:da)
> 		/bin/ip link set eth${i}_ name eth0
> 		;;
> 	*)
> 		/bin/echo "Unknown device ${MAC} left at eth${i}_" >&2
> 		;;
> 	esac
> 
> done
> ---
> 
> Of course this means you need to know the MAC address and the order you
> want them in and have physical access to the console.
> You could do all sorts of smart things like walking /sys/class/net/*/ or
> parsing dmesg to get the mappings you want.  You could also read the
> mappings from a file on disk (that way the script is unchanged from
> system to system)
> 
> Another option would be to build a custom kernel with the drivers built
> in.  Then they /must/ be initialised in a given order and will always
> get the same device name.
> 
> yet another option would be to work some udev magic to rename the
> interfaces as required when modules are loaded but I've got 0 experience
> with that.
> 
> I guess it all depends on how many machines your talking about and how
> hackish you're prepared to be, and how kind you want to be to whomever
> comes after you :).  There are lots of options.
> 
> Yours Tony
> 
>    linux.conf.au       http://linux.conf.au/ || http://lca2007.linux.org.au/
>    Jan 15-20 2007      The Australian Linux Technical Conference!
> 
> -- 
> linux mailing list
> linux at lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux

-- 
Tomasz M. Ciolek	
*******************************************************************************
 tmc at vandradlabs dot com dot au 
*******************************************************************************
   GPG Key ID:		0x41C4C2F0
   GPG Key Fingerprint: 3883 B308 8256 2246 D3ED  A1FF 3A1D 0EAD 41C4 C2F0
   Key available on good key-servers
*******************************************************************************


More information about the linux mailing list