⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hotplug.txt

📁 wireless tools是linux下的一套对无线网卡进行配置的工具
💻 TXT
📖 第 1 页 / 共 3 页
字号:
		Sane Hotplug network interface management		-----------------------------------------INTRODUCTION------------	In the old day, all Wireless cards were managed by theexcellent Pcmcia subsystem and its rich configuration scripts, andlife was happy. Then came the wireless PCI cards, then the wirelessUSB dongles. Some unification was needed, and rather than adapt thePcmcia subsystem for PCI and USB, it was decided to create the muchsimpler Hotplug systems.	The USB subsystem already use Hotplug, and the Pcmciasubsystem is migrating to it, CardBus cards (32 bits) already useHotplug, whereas Pcmcia cards (16 bits) still use the old Pcmciascripts.	The Hotplug system is still in its infancy, but already showsome good promises. Most users are disapointed at first by itsapparent lack of features compared to the Pcmcia scripts. In thisdocument, we will show how to fully exploit the Hotplug system and tryto implement the equivalent of all the functionality of the Pcmciascripts.ASSUMPTIONS-----------	The target audience of this document is mostly power users anddistribution maintainers, but it should give enough clues to helpnewbies. You should have read and understood DISTRIBUTIONS.txt. Theprocedures described here are more advanced than the simpleconfiguration described in DISTRIBUTIONS.txt.	The main focus is of course removable wireless interfaces, butwe will try to keep things generic and talk of the whole networkinterface management, so this should apply also to built-in Ethernetcards.PROBLEM STATEMENT-----------------	Let assume a Linux system and two or more network devices,Device A and Device B. Those devices may be built-in or removable,they may be present or absent from the system at any time, andactivated in any particular order.	The user wants to assign Configuration A to Device A andConfiguration B to Device B, without the possibility that Device A getassigned Configuration B.	Different users may have different definition of what isDevice A. For some, it's a specific instance of a specific hardware,for others any hardware that meet some criteria (a wireless card, anEthernet card).	The user may also want to have multiple configurationsdepending on various factors (like the old Pcmcia schemes). Device Amay get Configuration A1 or Configuration A2 depending on thosefactors.	By default, all network interfaces are created using a defaultinterface name (starting at "eth0" and going up). I call that problem"all my cards are eth0". And by default, "eth0" point to a singlefixed configuration in the configuration database. Clearly, this won'tsatisfy our requirements.EXAMPLE SYSTEM--------------	The distribution I use is Debian 3.0, and some parts will bespecific to it. However, it should be easy to translate to otherdistributions and I welcome additions to this document.	The example system is as follows :		o Linux 2.6.X SMP kernel with hotplug support		o Fully modular system (all network drivers as modules)		o PCI Ethernet card : AMD PCnet LANCE (pcnet32 - eth4)		o PCI Ethernet card : HP 100VG J2585B (hp100 - eth2)		o ISA Wireless card : Old AT&T Wavelan (wavelan - eth3)		o ISA-Pcmcia bridge : VADEM VG-469 (i82365 - slot 0)		o PCI-CardBus bridge : Ricoh RL5c475 (yenta_socket - slot 2)		o Pcmcia 802.11 card : Aironet 350 (airo_cs - eth0)		o Pcmcia 802.11 card : Lucent Orinoco (orinoco_cs - eth0)		o CardBus 802.11 card : SMC 2835W (prism54 - prism0)	This system just happen to be my Linux development box, andhas enough interfaces to make it interesting. All the example I quotein this document are extracted from this fully working system.BASIC CONCEPTS--------------	Most of the concept and tricks presented here are not reallynew, the main contribution is to integrate them together and make themwork.	1) Removable network interfaces are managed by Hotplug(Pcmcia, CardBus, USB...). We can't assume that those interfaces arealways present in this system and available at boot time (Pcmcia cardsare not made to be soldered in the Pcmcia slot), therefore Hotplug isthe only way to go.	2) Built-in PCI and ISA cards are managed by the init scripts,like they have always been. The ISA subsystem will never have Hotplugsupport, and hotplug is not necessary for PCI cards.	3) Built-in devices that are disable most of the time shouldbe enabled manually.	4) (1), (2) and (3) must be compatible on the same system andplay nice with each other.	5) A well defined and consistent network interface name isassigned to each network hardware interface using 'ifrename'. Device Ais always named 'ethA' (or whatever name you like such as'mynetworkcard').	6) No interface is called 'eth0' (or 'wlan0'). Any unknowndevice would be 'eth0', thefore known device should avoid using itbecause it might be already taken.	7) Multiple configurations for a single interface (schemes)are managed by the ifup/ifdown subsystem.CONFIGURATION FROM INIT SCRIPTS-------------------------------	It may seems paradoxal, but before setting up Hotplug, we needto make sure that the initialisation of network cards via initscripts is done properly and doesn't get in our way.	The configuration of network cards via init scripts is thetraditional way network is initialised in Linux. The advantage of thismethod is that it's very well documented and understood, and has notchanged much over the years. Unfortunately, it doesn't supportproperly removable cards.	The init scripts perform the following 3 functions in thatorder :		1) load necessary driver modules		2) rename interface to name chosen by the user		3) configure those interfaces	1) Applicability	----------------	Configuration from init scripts is applicable to any built-innetwork interface (ISA, PCI...), i.e. interfaces availalble at boottime and that will never be removed from the system.	The Hotplug subsystem has also the ability to configure someof the built-in network interfaces, such as PCI cards. However, thereis a class of devices that will never have Hotplug support, such asISA and EISA cards, and for those Hotplug won't work.	The advantage of using the init script method is that you areprobably already familiar with it and you have the ability to selectwhich interfaces should be configured at boot and which interfaceshould only be enabled manually (whereas Hotplug just configureseverything).	2) Loading driver modules (if/as needed)	----------------------------------------	Most distributions build the kernel drivers as modules. Thismodular setup allow to minimise the amount of memory used by thesystem and the flexible loading/unloading of drivers.	You can also compile your kernel with static drivers(non-modular). In that case, the driver will always be available inyour kernel, you don't need to configure the module subsystem, so youcan skip directly to the next section.	There are 3 alternatives to manage device drivers asmodules. Some distribution have explicit list of modules that areloaded at boot time, if you want to use that feature you need to checkyour distribution. Some system, such as hotplug or kudzu, can scan thevarious buses of the PC and load the appropriate drivers, and this ismostly configuration-free, but may not support all devices. The modulesubsystem also allow to load modules 'on-demand'.	I personally prefer to use the 'on-demand' feature of themodule subsystem has, as it allows you to not have to specify the listof modules that need to be loaded, and only modules really necessaryare loaded which save kernel memory. You can also choose which moduleto load when there are multiple altenate modules valid for yourhardware (which happens quite often).	With kernel 2.6.X, the module subsystem is configured in/etc/modprobe.conf. To configure 'on-demand' module loading, I need toadd to this file the following lines :--------- /etc/modprobe.conf ----------------# HP 100VG J2585B PCI cardalias eth2 hp100# AMD AMD PCnet LANCE PCI cardalias eth4 pcnet32# Old AT&T Wavelan ISA cardalias eth3 wavelanoptions wavelan io=0x390 irq=15---------------------------------------------	Your distribution may already have lines for your interfaces,either replace them or make sure they are correct (some distro arenotorious for picking the wrong driver name). This file also containsconfiguration for lot of other subsystems, obviously you don't want totouch that.	In this file, you put the name you would like the interface tohave (we'll fix that in a minute). You note that for modern PCI cards,this is much more straightforward than for old ISA cards.	3) Installing 'ifrename'	------------------------	You will need to install ifrename on your system. 'ifrename'is part of the Wireless Tools package (version 27 and later) and is acomplete rewrite of the now obsolete 'nameif'.	Some distributions, such as Debian Sarge, offer a specificpackage for 'ifrename', and in this case you should just install thispackage. Other distributions may include ifrename as part of their'wireless tools' package (this should be the case for Geentoo andMandrake). Other distributions, such as Debian 3.0, don't includeifrename at all, and you should compile yourself a recent version ofWireless Tools (v27 or later) and install it.	In any case, you should verify if 'ifrename' is properlyinstalled, and what is the path to call it.--------------------------> which ifrename/sbin/ifrename--------------------------	Most distributions will install 'ifrename' in '/sbin', while ifyou compile your own wireless tools, it will be in '/usr/local/sbin'.	4) Making the boot scripts call 'ifrename'	------------------------------------------	You need to make sure 'ifrename' is run at boot time. Mostdistributions don't do that yet by default.	This is a part that is distribution specific, so you will needto look into your init files. It will need to run just before the callto 'ifup' or 'ifconfig' command.	In Debian 3.0, it needs to be run from /etc/init.d/networking,which is not the default. The necessary patch is below :------------------------------------------------------------------- networking-orig     Wed Feb 18 13:56:23 2004+++ networking  Fri Feb 20 14:51:06 2004@@ -120,6 +120,15 @@ case "$1" in         doopt syncookies no         doopt ip_forward no +       # Optionally remap interface names based on MAC address.+       # '/sbin/ifrename' is part of wireless-tools package.+       # /etc/iftab is currently not created by default. Jean II+       if [ -x /sbin/ifrename ] && [ -r /etc/iftab ]; then+           echo -n "Remapping network interfaces name: "+           ifrename -p+           echo "done."+       fi+         echo -n "Configuring network interfaces: "         ifup -a        echo "done."----------------------------------------------------------------	Don't forget to set the appropriate path to call ifrename (seestep (3) above).	You may want to also set the proper options for ifrename(check the man page).	The option '-p' enable module autoloading compatibility.	The default version of 'ifrename' also includes some specificDebian support : using "ifrename -p -d", only the proper modules areloaded. If you are using Debian, you should use this option.	5) Renaming interfaces	----------------------	As stated above, we use 'ifrename' to assign names tointerfaces.	First, you need to get the MAC address of each of youinterface. You can read it on the label on the card or display itusing the 'ifconfig' command. Remember that the interface won't loadyet with the proper name, so you may need to do a bit looking around :-----------------------------> modprobe pcnet32> ifconfig eth0eth0      Link encap:Ethernet  HWaddr 00:10:83:34:BA:E5  [...]-----------------------------	The configuration of 'ifrename' is simple, you just specifywhich name should be used for each MAC address in the file/etc/iftab :--------- /etc/iftab ------------------------# HP 100VG J2585B PCI cardeth2		mac 08:00:09:*# Old AT&T Wavelan ISA cardeth3		mac 08:00:0E:*# AMD AMD PCnet LANCE PCI cardeth4		mac 00:10:83:*---------------------------------------------	The '*' in the MAC address is a wildcard and allow me toreplicate my configuration between multiple identical computers. Ifyou have to manage large number of computers (like a rack of server orclusters), you may want to look at other selectors offered by'ifrename', such as the ability to base interface name on BusInformation.	To test that ifrename works, do the following :		o load all your drivers, see section (2)		o check /proc/net/dev to see which interface exist		o bring all interfaces down : ifconfig ethX down		o run ifrename		o check each interface with ifconfig	6) Configuring interfaces	-------------------------	Most likely, your distribution is already doing this partproperly. Just assign the proper IP and wireless configuration to eachof the interface name you have chosen.	This part is distribution specific, and I already document itin the file DISTRIBUTIONS.txt.	In Debian, you would need to modify the file/etc/network/interfaces like this :--------- /etc/network/interfaces -----------# AMD AMD PCnet LANCE PCI cardauto eth4iface eth4 inet dhcp# HP 100VG J2585B PCI cardauto eth2iface eth2 inet static    address 10.0.0.2    network 10.0.0.0    netmask 255.255.255.0    broadcast 10.0.0.255    gateway 10.0.0.1---------------------------------------------	This was the last part. Now, at your next boot, all yourinterfaces should be assigned the proper name and properconfiguration.CONFIGURATION VIA HOTPLUG-------------------------	Dealing with removable interfaces is similar to built-in

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -