Mnemovore

ad hoc-ing around

leave a comment »

The past days i got a wireless adapter and setup an ad hoc network to be able to use some wireless devices. There’s still the matter of WEP vs WAP(2) thing but nevertheless with a good password you’re good to go in both cases. Also there’s the option to increase/decrease the signal strength so security is just a matter of usage.

Anyway, i made a small console script for WEP and a bit of configuration for WAP(wpa_supplicant) and :

#!/bin/bash
#
# TODO: Option to set signal strength
#
 
echo "Create Ad-Hoc Network"
echo "_____________________"
echo

INTERFACE="wlan0"

echo -n "Type prefered ESSID (e.g. My Network, Conan's home, etc): "
read ESSID
echo -n "Insert prefered Mode (e.g. ad-hoc, master, managed etc): "
read MODE
echo -n "Channel (e.g.auto, 3, etc)  : "
read CHANNEL
echo -n "Desired pass key : "
read KEY
echo -n "IP Address : "
read IP_ADDRESS
echo -n "Netmask : "
read NETMASK
echo

ifconfig $INTERFACE up
ifconfig $INTERFACE $IP_ADDRESS netmask $NETMASK
iwconfig $INTERFACE mode $MODE
iwconfig $INTERFACE essid $ESSID
iwconfig $INTERFACE channel $CHANNEL


echo "Setting up key passphrase.."
iwconfig $INTERFACE key $KEY

echo -n "Seems that all is good.."
echo -n "Press any key to continue..."
read

Yeah i know its very simple but it works for me 😛 If one of the steps fails you ll see an indication.

As for WPA i changed a bit my wpa_supplicant.conf to look like this:

ctrl_interface=/var/run/wpa_supplicant

# By default, only root (group 0) may use wpa_cli

ctrl_interface_group=0
eapol_version=1
ap_scan=2
fast_reauth=1

# WPA protected network, supply your own ESSID and WPAPSK here:
network={
#  scan_ssid=0
  ssid="CONAN-DUDE"
  mode=1
  proto=WPA2
  key_mgmt=WPA-PSK
  pairwise=CCMP TKIP
  group=CCMP TKIP #WEP104 WEP40
  psk="*****************************"
}

# Plaintext connection (no WPA, no IEEE 802.1X),
# nice for hotel/airport types of WiFi network.
network={
  key_mgmt=NONE
  priority=0
}

and just issued the below (in a script)

killall wpa_supplicant
ifconfig wlan0 down
ifconfig wlan0 up
iwconfig wlan0 essid "CONAN-DUDE" channel auto
iwconfig wlan0 mode ad-hoc
wpa_supplicant -D wext -iwlan0 -dd -Bw -c /etc/wpa_supplicant.conf
dhclient wlan0

I have the intel 3945 wireless adapter so wext is the option for it.
For testing i run
iwlist wlan0 scan

I still have a masochistic preference for wired networks though ;p

Advertisements

Written by aperturefever

April 14, 2009 at 10:29 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: