Tuesday, July 10, 2007

Creating an Ad-Hoc network

This is a short reference how to create an Ad-hoc network in Linux using the CLI. More detailed article can be found in this Ubuntu guide.


1. Put the wireless interface in ad-hoc mode


iwconfig eth1 mode ad-hoc


2. Set the channel/frequency that you want to use


iwconfig eth1 channel 11


3. Add the name (ssid) for the network you want to create/join. Use single quotes if there is a space in the name.


iwconfig eth1 essid ‘name’


4. Add a WEP encryption key


iwconfig eth1 key ’s:mykey’


5. Bring the interface back up


ifconfig eth1 up


With Atheros based cards you have to take the VAP down in order to create the interface in ad-hoc mode. There are two ways to do this


# rmmod ath_pci


# modprobe ath_pci autocreate=adhoc


# wlanconfig ath0 destroy


# wlanconfig ath create wlandev wifi0 wlanmode adhoc


With cards using ndiswrapper this should work as follows:


# rmmod ndiswrapper


# modprobe ndiswrapper


The example above shows how to setup the network with WEP encryption. If you want to use WPA you have to install wpa_supplicant and configure wpa_supplicant.conf like this:


network={
ssid=”myadhoc”
mode=1
proto=WPA
key_mgmt=WPA-NONE
pairwise=NONE
group=TKIP
psk=”verysecretpass”
}


Then start wpa_supplicant with


# wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant.conf -ieth1 -Dwext -Bw


Of course you have to put the correct interface and driver name for this to work.

No comments:

Post a Comment