following code: [ -x /usr/sbin/ifrename -a -r /etc/iftab ] && /usr/sbin/ifrename should be placed into one of the baselayout scripts. I don't know which would be the best. candidates are: /etc/init.d/bootmisc /etc/init.d/net.lo if you have more than one network adapter, then you need 'ifrename' to ensure, that you have the right interface names assigned. ifrename is located in net-wireless/wireless-tools, but is THE solution for all your interface naming problems. Not just for wireless cards! ;-) btw: it would be nice for network hotplugging, to have some kind of wildcard net.* scripts. for example: I've set 'usbnet*' in /etc/iftab, so all USB network adapters gets names like usbnet0, usbnet1, etc. Now I have to symlink all possible numbers from net.lo to net.usbnet0, etc. it would be nice, if just 'net.usbnet' would also work. First you should look, if "net.<fullname>" exist. If not, then strip the numbers from the right and look if "net.<name>" exists. This way you could have wildcard setups for some kind of network adapters. Reproducible: Always Steps to Reproduce:
oh well, 'ifrename' should be run as early as possible. At least before the module-autoload stuff.
sounds like you should make a ifrename net module
I looked at the source code of 'ifrename' and it seems, that I was wrong with when it should be executed. It just renames the existing interfaces. So in /etc/hotplug/net.agent, it is a good place for all hotplug devices. And it's already there. But for renaming static devices (i.e. PCI cards), it would be also good to execute 'ifrename' once. So the right time would be after module-loading, but before net.* I don't think, we need an own init-script for this. This would be overkill. If we find a good existing place, then this is the way to go. Otherwise I can make such a script. It has to go to wireless-tools then. But I really prefer some existing script.
are there any docs about the net-modules architecture? the examples in /lib/rcscripts/net.modules.d are not really good if you want to write your own plugin and want to do it RIGHT in every aspect.
I used ifrename in my Gentoo by adding the following to my /etc/conf.d/net: preup() { if [ -x /usr/sbin/ifrename -a -r /etc/iftab ] ; then /usr/sbin/ifrename -n ${IFACE} fi } and then just edited /etc/iftab with the names and parameters I wanted like: intel* mac 00:11:11:43:11:CF 3com* mac 00:0A:5E:56:99:DC I think it's a good way to use it, but it will be much better if this code is available as a module. (I'll try to write it if there is interest.)
ifrename must happen before net scripts are called, otherwise dependancies on specific net scripts may fail. hotplug calls ifrename if it's available. If the interface module is in the kernel, then an init script should be called before net scripts. Assigning to mobile herd as ifrename is part of wireless-tools.
The recommended way of renaming network interfaces is by using udev. See http://www.reactivated.net/writing_udev_rules.html#example-iface
cool. accepted. ;-) But: this also affects hotplug-network-cards. So it would be cool to install a sample rule-file. As an extra file (i.e. /etc/udev/rules.d/30-net), so one can find it easily and setup it as needed. Sample entries should be comment out of course. I think, this is a much cleaner and more consistent method than ifrename (via /etc/iftab).
(In reply to comment #8) > cool. accepted. ;-) > > But: this also affects hotplug-network-cards. So it would be cool to install a > sample rule-file. As an extra file (i.e. /etc/udev/rules.d/30-net), so one can > find it easily and setup it as needed. Sample entries should be comment out of > course. > > I think, this is a much cleaner and more consistent method than ifrename > (via /etc/iftab). I agree that this is a very nice and logical way to rename interfaces, but I think it's not good for gentoo to force the use of udev. After all gentoo is quite about flexibility and not letting an alternate method will exclude Gentoo/!Linux (*BDS, Darwin, Hurd, ...) and may harm embedded Gentoo Linux. (In reply to comment #6) > ifrename must happen before net scripts are called, otherwise dependancies on > specific net scripts may fail. So if there is a way to force that this will be the first script to run before any other script. Something like: ifrename_depend() { before macchanger interface wireless } Then this will make a good fallback for non Linux 2.6 + udev systems. (The network script will certainly need to be extended for use on non linux systems, but it'll me there to be extended) Yuri.
The best, and most generic, way to do this is by using udev. Closing as WONTFIX.
Writing udev rules can be overly complicated for many users
baselayout-1.12.0-alpha3 will ship with a "rename" module that allows device renaming rename_001122334455="foo1" # rename based on MAC address renaem_eth0="foo2" #rename based on current name
Fixed in baselayout-1.12.0_pre1-r1