Connect Wireless router via Ubuntu command line

Posted on

QUESTION :

I would like to connect to my TP_Link Wireless router via command line (from an Ubuntu Server). I’m trying with this:

ifconfig wlan0 down
iwconfig wlan0 essid {MY ESSID}
iwconfig wlan0 key s:{PASSWORD}
ifconfig wlan0 up

At this point, my iwconfig wlan0 output looks good, then I request an IP from the AP’s DHCP server:

dhclient -r
dhclient wlan0

This last command hangs for 2-3 minutes, then exits without any output. The iwconfig wlan0 output the same, still “Access Point: Not-Associated”
Looks like I cannot get an IP.

Can anybody help what is the problem?

ANSWER :

Sorry iwconfig only works for WEP encryption.

please use the wpa_supplicant


edit the /etc/wpa_supplicant.conf file using gedit or vim or what ever you prefer.

append to the end of the file

network={
    ssid="my network"
    scan_ssid=1 //this must be added if the AP doesnt broadcast its ssid
    psk="sekret"
}

then you can manually turn on the supplicant

# wpa_supplicant -B -i interface -c /etc/wpa_supplicant.conf

once connected you can obtain an address via dhcp with

# dhcpd interface

Leave a Reply

Your email address will not be published. Required fields are marked *