Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to connect to my WEP network just using the command-line (Linux).

I run:

sudo iwconfig wlan0 mode Managed essid 'my_network' key 'xx:xx:... hex key, 26 digits'

Then I try to obtain an IP with

sudo dhclient -v wlan0

or

sudo dhclient wlan0

without success (tried to ping google.com).

I know that the keyword is right, and I also tried with the ASCII key using 's:key', and again, the same result.

I get the message below when running dhclient:

Listening on LPF/wlan0/44:...
Sending on   LPF/wlan0/44:...
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3 

I have no problem connecting with WICD or the standard Ubuntu tool.

share|improve this question
1  
Side note - don't use WEP, use WPA2 –  icyrock.com Sep 29 '13 at 2:12
    
Can you please post the results of iwconfig without any parameters too. What version of Linux are you using? –  Danijel J Sep 29 '13 at 4:20
    
The OP might use WEP for his own reason. It is considered shallow in perspective of security, but some people just still prefer it. –  Danijel J Sep 29 '13 at 4:41

3 Answers 3

There is Danijel J's two options are good, but there is also a 3rd option if you have this working via the 'standard Ubuntu tool' using nmcli, which should already be installed at /usr/bin/nmcli.

First, run

nmcli c

This will list your connections, with the first column being the SSID, and the second column being the UUID of the connection.

Copy the UUID of the SSID you want to connect to so you can paste it into the next command.

Next, run

nmcli c up uuid <paste uuid here>

and this will, using the same stuff as the 'standard Ubuntu tool' connect to your wifi!

share|improve this answer

Install wpa_supplicant and you have a nice software for all of your Wireless needs. You can then use wpa_cli command to access and set your network interactively. there is also a number of 3rd party software available acting as a GTK+ or QT GUI for wpa_supplicant if you want to go gui at anytime.

Also you could set the connection configuration in /etc/wpa_supplicant.conf or /etc/wpa_supplicant/wpa_supplicant.conf depend on you linux OS. for more information on interactive command type h inside wpa_cli.

share|improve this answer

Option 1

Just edit /etc/network/interfaces and write:

auto wlan0
iface wlan0 inet dhcp 
                wpa-ssid {ssid}
                wpa-psk  {password}

After that write and close file and use command:

sudo dhclient wlan0

Replace {ssid} and {password} with your respective WiFi SSID and password.


Option 2

This is going to be more of a 1. Assuming your Wireless network card is wlan0 2. Assuming your Wireless network is "Wifi2Home" 2. Assuming your Wireless network key is ASCII code ABCDE12345

First, get your WiFi card up and running:

sudo ifconfig wlan0 up

Now scan for a list of WiFi networks in range. You might be typing your name wr$

sudo iwlist wlan0 scan

This will show you a list of wireless networks, pick yours from the list:

sudo iwconfig wlan0 essid Wifi2Home key s:ABCDE12345

To obtain the IP address, now request it with the Dynamic Host Client:

sudo dhclient wlan0

You should then be connected to the WiFi network. The first option is better, because it will be able to run as a cron job to start up the wifi whenever you need it going. If you need to turn off your WiFi for whatever reason, just type:

sudo ifconfig wlan0 down

FYI

I have also seen people using alternative commands. I use Debian, Solaris and OSX, so I'm not 100% sure if they are the same on Ubuntu. But here they are:

sudo ifup wlan0 is the same as sudo ifconfig wlan0 up
sudo ifdown wlan0 is the same as sudo ifconfig wlan down

share|improve this answer
    
The last two commands aren't the same. «ifconfig … up» just activates an interface, wheres «ifup …» besides activating also setups IP addresses and some other options. –  Hi-Angel Oct 19 at 8:09
    
I like version 2 very much! Only I get: Error for wireless request "Set Encode" (8B2A) : SET failed on device wlan0 ; Invalid argument. And this is the command I used (just like you suggested): sudo iwconfig wlan0 essid mywifiname key s:THEPASSWORD. Can you help? –  nourdine Nov 28 at 23:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.