Refering to devices via MAC address and not the Linux device name.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I needed to make this change, and perhapse other will too at some stage...
I'd like to refer to a device via its MAC address, and not the device name
(eg eth0, eth1) that the OS gives it. This is specially useful where adding
a new network card pre-build results in the would-be eth0 and eth1 to become
eth2 and eth3, and the added in card to take over eth0 and eth1.



Anywho, an example...

network --bootproto static --device 00:17:a4:10:26:66 --ip 153.107.77.11
--netmask 255.255.255.0 --gateway 153.107.77.1 --hostname
penguin0.appmgmtu.det.nsw.edu.au

network --bootproto dhcp --device 00:17:a4:10:26:65



...and the patch...


============================================================================
# cat installclass.py.patch
16a17,18
> import re
> 
331a334,355
> 
>                 #XXX Nima's Patch Begin XXX#
>                 re_mac =
re.compile(r"((?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2})");
>                 if re_mac.match(device):
>                     hwaddr = str.upper(device)
>                     device = None
>                     f = open("/proc/net/dev")
>                     lines = f.readlines()
>                     f.close()
>                     lines = lines[2:]
>                     for line in lines:
>                         nextDev = string.strip(line[0:6])
>                         try:
>                             if hwaddr == isys.getMacAddress(nextDev):
>                                 device = nextDev;
>                                 break;
>                         except Exception, e:
>                             log("exception getting mac addr: %s", e,)
> 
>                 assert device is not None;
>                 #XXX Nima's Patch End XXX#
> 


============================================================================
# cat network.py.patch
315a316,335
> 
>                     #XXX Nima's Patch Begin XXX#
>                     re_mac =
re.compile(r"((?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2})");
>                     if re_mac.match(dev.get('device')):
>                         hwaddr = dev.get('device')
>                         dev = None
>                         f = open("/proc/net/dev")
>                         lines = f.readlines()
>                         f.close()
>                         lines = lines[2:]
>                         for line in lines:
>                             nextDev = string.strip(line[0:6])
>                             try:
>                                 if hwaddr == isys.getMacAddress(nextDev):
>                                     dev = nextDev;
>                                 break;
>                             except Exception, e:
>                                 log("exception getting mac addr: %s", e,)
>                     #XXX Nima's Patch End XXX#
> 


..you can then force a change in order via the /etc/mactab. Also
/etc/modules.conf file would probably need an adjustment if you do this as
the aliases the wrong way around.

Nima


**********************************************************************
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**********************************************************************


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux