#!/bin/sh
#Depending on how you want to connect, one or more the
#following need to be set
IFACE="wlan0"
# Set to Y if you want the interface rebuilt
SETUP="Y"
# type - managed / monitor / ad-hoc
TYPE="managed"
# authentication: open = Open authentication / restricted = Shared key
AUTHENTICATION="open"
ESSID="linksys"
# specify the Access Point MAC address or "any" (or sometimes needs to be "auto")
APMAC="00:18:F8:43:CE:C1"
CHANNEL="1"
#WEPKEY=""
#WEPKEY=""
#WEPKEY=""
#rate 2MB, 11MB, 54MB, auto
RATE="auto"
# Specify an empty string / 192.168.155.82 / dhcp
IPADDR="dhcp"
#IPADDR="192.168.25.89"
# When using a specific IP, define the netmask
NETMASK="netmask 255.255.255.0"
ifconfig $IFACE down
pkill dhclient
if [ x$SETUP = "xY" ]
then
#/root/wireless/s/wlan0down
# /root/wireless/s/wlan0rmv
#/root/wireless/s/wlan0up
rmmod r8187
echo "rmmod r8187 finished"
modprobe r8187
echo "modprobe r8187 finished"
# macchanger -a wlan0
ifconfig $IFACE down
echo "ifconfig $IFACE down finished"
fi
if [ x$WEPKEY = "x" ]
then
iwconfig $IFACE key off
echo "WEP encryption has been turned off"
else
iwconfig $IFACE mode managed key $WEPKEY $AUTHENTICATION
echo "iwconfig $IFACE mode managed key $WEPKEY $AUTHENTICATION finished"
echo "WEP encryption has been set to $WEPKEY"
echo "Authentication has been set to $AUTHENTICATION"
fi
# The following only works for 128 bit WEP
#iwconfig ath0 key "s:greenline"
# Set the MAC address of the AP to connect to
if [ x$APMAC = "x" ]
then
echo "Access Point MAC has not been set"
else
iwconfig $IFACE ap "$APMAC"
echo "Access Point MAC has been set to $APMAC"
fi
# Set the essid to connect to
if [ x$ESSID = "x" ]
then
echo "ESSID has not been set"
else
iwconfig $IFACE essid "$ESSID"
echo "ESSID has been set to $ESSID"
fi
#Set the interface speed
iwconfig $IFACE rate $RATE
echo "Interface speed rate was set to $RATE"
if [ x$TYPE = "xmonitor" ]
then
iwconfig $IFACE mode monitor channel $CHANNEL
echo "Mode has been set to Monitor"
iwpriv $IFACE rawtx 1
# iwconfig $IFACE channel $CHANNEL
echo "Channel has been set to $CHANNEL"
ifconfig $IFACE up
iwconfig
else
ifconfig $IFACE up
if [ x$IPADDR = "x" ]
then
echo "No IP address has been set"
else
if [ x$IPADDR = "xdhcp" ]
then
echo "IP Addressing via DHCP has been selected"
sleep 1
dhclient -1 $IFACE
else
# ifconfig $IFACE <IP address> netmask <netmask> up
echo "IP Addressing has be set to $IPADDR $NETMASK"
ifconfig $IFACE $IPADDR $NETMASK up
# route add default gw <gateway address>
#route add default gw 192.168.55.20
# gedit /etc/resolv.conf
fi
fi
fi
sleep 2
iwconfig $IFACE rate $RATE
ifconfig $IFACE up
sleep 2
ifconfig $IFACE
iwconfig $IFACE
echo " "