Rev 3 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/bin/bash# Network Interface Configuration System# Copyright (c) 1996-2009 Red Hat, Inc. all rights reserved.## Based on PCMCIA wireless script by (David Hinds/Jean Tourrilhes)## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License, version 2,# as published by the Free Software Foundation.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA## Configure wireless network device options. See iwconfig(8) for more info.# Valid variables:# MODE: Ad-Hoc, Managed, etc.# ESSID: Name of the wireless network# NWID: Name of this machine on the network. Hostname is default# FREQ: Frequency to operate on. See CHANNEL# CHANNEL: Numbered frequency to operate on. See FREQ# SENS: Sensitivity threshold for packet rejection.# RATE: Transfer rate. Usually one of Auto, 11, 5, 2, or 1.# KEY: Encryption key for WEP.# RTS: Explicit RTS handshake. Usually not specified (auto)# FRAG: Fragmentation threshold to split packets. Usually not specified.# SPYIPS: List of IP addresses to "spy" on for link performance stats.# IWCONFIG: Extra parameters to pass directly to IWCONFIG# SECURITYMODE: Security mode, e.g: 'open' or 'restricted'# IWPRIV: Extra parameters to pass directly to IWPRIV# WOWLAN: Enable wowlan (any, disconnect, magic-packet,...)# Only meant to be called from ifup.# Mode need to be first : some settings apply only in a specific mode !if [ -n "$MODE" ] ; theniwconfig $DEVICE mode $MODEfi# Set link up (some cards require this.)/sbin/ip link set dev ${DEVICE} up# This is a bit hackish, but should do the job right...if [ -n "$ESSID" -o -n "$MODE" ] ; thenNICKNAME=$(/bin/hostname)iwconfig $DEVICE nick "$NICKNAME" >/dev/null 2>&1fi# Regular stuff...if [ -n "$NWID" ] ; theniwconfig $DEVICE nwid $NWIDfiif [ -n "$FREQ" -a "$MODE" != "Managed" ] ; theniwconfig $DEVICE freq $FREQelif [ -n "$CHANNEL" -a "$MODE" != "Managed" ] ; theniwconfig $DEVICE channel $CHANNELfiif [ -n "$SENS" ] ; theniwconfig $DEVICE sens $SENSfiif [ -n "$RATE" ] ; theniwconfig $DEVICE rate "$RATE"fiif [ -n "$KEY" -o -n "$KEY1" -o -n "$KEY2" -o -n "$KEY3" -o -n "$KEY4" ] ; then[ -n "$KEY1" ] && iwconfig $DEVICE key "[1]" $KEY1[ -n "$KEY2" ] && iwconfig $DEVICE key "[2]" $KEY2[ -n "$KEY3" ] && iwconfig $DEVICE key "[3]" $KEY3[ -n "$KEY4" ] && iwconfig $DEVICE key "[4]" $KEY4[ -n "$DEFAULTKEY" ] && iwconfig $DEVICE key "[${DEFAULTKEY}]"[ -n "$KEY" ] && iwconfig $DEVICE key $KEYelseiwconfig $DEVICE key offfiif [ -n "$SECURITYMODE" ]; theniwconfig $DEVICE enc $SECURITYMODEfiif [ -n "$RTS" ] ; theniwconfig $DEVICE rts $RTSfiif [ -n "$FRAG" ] ; theniwconfig $DEVICE frag $FRAGfi# More specific parameters passed directly to IWCONFIGif [ -n "$IWCONFIG" ] ; theniwconfig $DEVICE $IWCONFIGfiif [ -n "$SPYIPS" ] ; thenfor IP in $SPYIPS; doiwspy $DEVICE + $IPdonefiif [ -n "$IWPRIV" ] ; theniwpriv $DEVICE $IWPRIVfiif [ -n "$WOWLAN" ] ; thenPHYDEVICE=phy_wireless_device $DEVICEiw phy $PHYDEVICE wowlan enable ${WOWLAN}fi# ESSID need to be last : most device re-perform the scanning/discovery# when this is set, and things like encryption keys are better be# defined if we want to discover the right set of APs/nodes.if [ -n "$ESSID" ] ; theniwconfig $DEVICE essid "$ESSID"else# use any essidiwconfig $DEVICE essid any >/dev/null 2>&1fi