jueves, 4 de octubre de 2007

wpa sin networkmanager

Algo que no me convencía era depender de networkmanager (y de gnome por lo tanto) para poder asociarme a una red wpa, así que aquí va la papa..

ejemplo práctico:

root@casper:/# apt-get install wpasupplicant

root@casper:/# iwconfig
lo no wireless extensions.

eth0 no wireless extensions.

eth1 unassociated ESSID:"HOMELINUX"
Mode:Managed Frequency=2.462 GHz Access Point: Not-Associated
Bit Rate:0 kb/s Tx-Power=20 dBm Sensitivity=8/0
Retry limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:25 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:18 Missed beacon:0

root@casper:/# iwlist eth1 scan
eth1 Scan completed :
Cell 01 - Address: 00:0E:2E:8D:2A:2A
ESSID:"HOMELINUX"
Protocol:IEEE 802.11bg
Mode:Master
Channel:11
Encryption key:on
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
48 Mb/s; 54 Mb/s
Quality=91/100 Signal level=-37 dBm
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (1) : TKIP
Authentication Suites (1) : PSK
Extra: Last beacon: 32ms ago

editamos /etc/wpa_supplicant.conf y agregamos

ctrl_interface=/var/run/wpa_supplicant

network={
ssid="HOMELINUX"
proto=WPA RSN
key_mgmt=WPA-PSK
pairwise=TKIP CCMP
group=TKIP CCMP
psk="acavalaclaveentextoplano"
priority=5
}

y con esto ya estamos en condiciones de empezar a trabajar.

bastará con hacer:
wpa_supplicant -Bw -Dwext -ieth1 -c/etc/wpa_supplicant.conf

y revisar con iwconfig que estemos realmente asociados

root@casper:/# iwconfig
lo no wireless extensions.

eth0 no wireless extensions.

eth1 IEEE 802.11g ESSID:"HOMELINUX"
Mode:Managed Frequency:2.462 GHz Access Point: 00:0E:2E:8D:2A:2A
Bit Rate:54 Mb/s Tx-Power=20 dBm Sensitivity=8/0
Retry limit:7 RTS thr:off Fragment thr:off
Encryption key:5493-7EE8-B928-CB64-E684-7AE5-21BF-AF6A-6B89-B569-3A7B-853F-2133-45DE-384F-9EF6 Security mode:open
Power Management:off
Link Quality=85/100 Signal level=-45 dBm Noise level=-89 dBm
Rx invalid nwid:0 Rx invalid crypt:26 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:18 Missed beacon:0

por último tomaremos ip (en este caso por dhcp) con

dhclient eth1


Listening on LPF/eth1/00:16:6f:2f:a7:7c
Sending on LPF/eth1/00:16:6f:2f:a7:7c
Sending on Socket/fallback
DHCPREQUEST on eth1 to 255.255.255.255 port 67
DHCPACK from 192.168.1.1
bound to 192.168.1.11 -- renewal in 391401 seconds.
root@casper:/# ifconfig eth1
eth1 Link encap:Ethernet HWaddr 00:16:6F:2F:A7:7C
inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:81 errors:26 dropped:44 overruns:0 frame:0
TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:639358 (624.3 KiB) TX bytes:261481 (255.3 KiB)
Interrupt:17 Base address:0xa000 Memory:bc008000-bc008fff

Y eso es todo...

si queremos mantenerlo de forma persistente y evitar estos pasos basta con editar /etc/network/interfaces

auto eth1
iface eth1 inet dhcp
wireless-essid HOMELINUX
pre-up wpa_supplicant -Bw -Dwext -iethX -c/etc/wpa_supplicant.conf
post-down killall -q wpa_supplicant
EOF

No hay comentarios: