Wednesday, November 21, 2012

command line to connect wifi in Linux

=============== WPA only ============
step 1:
ifconfig wlan0 up
wpa_passphrase yournetworkessid passphrase > /opt/wpa_configure.conf

step 2, vi to edit more info into it:   (vi quick guide: start "vi filename" then press "i" for insert mode, after edit press ESC for cmd mode, type :w to write, :q to quit)

step 3, connect:
wpa_supplicant -iwlan0 -c/opt/wpa_configure.conf &

step 3, dhcp to get IP:
udhcpc -i wlan0

=============== WEP only =============
Tools to use:
ifconfig: Enable your wireless device.
iwlist: List the available wireless access points.
iwconfig: Configure your wireless connection.
dhclient: Get your IP address via dhcp.

Step 1: enable your wifi device (ifconfig wlan0 down)
ifconfig wlan0 up

Step 2: scan wifi network
iwlist wlan0 scan

Step 3: connect to the wifi (WEP only) network
iwconfig wlan0 essid NETWORK_ID key s:WIRELESS_PASSWORD

Step 4: dhcp to get IP address
udhcpc -i wlan0
OR dhclient wlan0

manual IP, gateway:
ifconfig wlan0 netmask up
route add default gw

============== to change mac address ========

ifconfig eth0 down hw ether 00:00:00:00:00:01
ifconfig eth0 up

No comments:

Post a Comment