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?

1 Answer 1


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

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

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
  • Man, you're a lifesaver. Thanks, wpa_supplicant works like a charm
    – RobbeR
    Nov 2, 2016 at 20:41
  • your very welcome. :-)
    – Bryan
    Nov 2, 2016 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .