scan for APs and ad-hocs

First, let us have a look at the existing APs around,

ifconfig NIC up
iwlist NIC scan | egrep 'Cell|SSID|Channel|802\.11'

we can also have a look at the ad-hoc cells,

draft, only the ad-hoc interface can see itself -- why?

ifconfig NIC down
iwconfig NIC mode ad-hoc
#iwconfig NIC channel 1

ifconfig NIC up
iwlist NIC scan

AP / managed

Connecting to some AP network,

#ubuntu
cp /usr/share/doc/wpa_supplicant/examples/wpa-psk-tkip.conf /etc/wpa.conf
chmod 600 /etc/wpa.conf
vi /etc/wpa.conf

(comment out ctrl_interface)
(change ssid and psk)

e.g.,

network={
        ssid="xxxx"
        key_mgmt=WPA-PSK
        proto=WPA
        pairwise=TKIP
        group=TKIP
        psk="xxxx"
}

cd ~/
#tail -F /var/log/kern.log /var/log/syslog
nohup wpa_supplicant -s -i NIC -c /etc/wpa.conf &

Getting an IP,

dhclient NIC

ad-hoc

ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc
iwconfig wlan0 channel X

ifconfig wlan0 up
iwconfig wlan0 rate 54Mb/s
iwconfig wlan0 essid 'ESSID'
ifconfig wlan0 x.x.x.x/xx up

refs