5

How do I connect my Raspberry Pi running Raspbian to an open wireless network using a USB wireless network adapter using the command line only?

The name of my wireless network is called "WildRouter," and here's how I've been trying to connect without success:

$ sudo iwconfig wlan0 essid WildRouter
$ sudo dhclient –v wlan0
Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/...
Sending on   LPF/wlan0/...
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 9
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 13
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 21
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 9
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
No DHCPOFFERS received.
No working leases in persistent database - sleeping.

What am I doing wrong?

Update 1
Then I tried following the "command line" section of this document, adding the following to my /etc/wpa_supplicant/wpa_supplicant.conf:

network={
    ssid="WildRouter"
}

Then ran the following:

$ sudo ifdown wlan0
$ sudo ifup wlan0
wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
Failed to connect to wpa_supplicant - wpa_ctrl_open: No such file or directory
wpa_supplicant: /sbin/wpa_cli daemon failed to start
run-parts: /etc/network/if-up.d/wpasupplicant exited with return code 1

It still doesn't seem to be working.

Update 2
This is the content of my /etc/network/interfaces:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

I added the psk to /etc/wpa_supplicant/wpa_supplicant.conf, leaving the value empty, because this is an open network (no password):

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
    ssid="WildRouter"
    psk=""
}

Even with adding psk, I still get the same result on "sudo ifup wlan0."

Update 3
The output from sudo iwlist wlan0 scan:

Cell 04 - Address: B2:44:C8:23:CC:A7
ESSID:"WildRouter"
Protocol:IEEE 802.11bg
Mode:Master
Frequency:2.437 GHz (Channel 6)
Encryption key:off
Bit Rates:54 Mb/s
Quality=58/100  Signal level=100/100 
rav_kr
  • 446
  • 5
  • 12
user2245766
  • 153
  • 1
  • 1
  • 4

2 Answers2

2

If you are using a low power source like laptop USB port or external battery try to connect it to electricity using a 5V charger.

Try the following:
I do a static config for eth0 bcz its easier for me to get the IP address but u also have to configure your wired device into the same subnet

$ nano /etc/network/interfaces

auto lo iface lo inet loopback #you can delete the eth0 config iface eth0 inet static address 192.168.5.10 netmask 255.255.255.0 gateway 192.168.5.1 network 192.168.5.0 broadcast 192.168.5.255

auto wlan0 iface wlan0 inet dhcp wireless-essid WildRouter wireless-key

save and close

sudo ifdown wlan0
sudo ifup wlan0

unplug the ethernet cable

1

You haven't posted enough information to say "What am I doing wrong", not least where you got the information to try what you have done.

The following shows 3 ways of setting up WiFi, http://www.raspberrypi.org/documentation/configuration/wireless/README.md

Te easiest is to set up using GUI, but if you follow the detailed instructions you can do via the command line.

PS These instructions assume you haven't already destroyed the default settings in /etc/network/interfaces which should be something like

This applies to Raspbian Wheezy prior to 2015-05-05 for later (and Jessie) See How do I set up networking/WiFi/Static IP

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp
Milliways
  • 59,890
  • 31
  • 101
  • 209
  • Hello, thanks for the helpful link. I have updated my question with the results of what I tried based on the information in the link you provided. Still not working. Those are all the details I have. – user2245766 Jan 18 '15 at 01:14
  • Post the content of your /etc/network/interfaces the default should look like the above. You need the psk in wpa_supplicant.conf – Milliways Jan 18 '15 at 02:16
  • Hi again, I've updated the post with the content of /etc/network/interfaces. I tried adding psk to wpa_supplicant.conf as you suggested, but with the same result. I've also updated the post to reflect adding psk. – user2245766 Jan 18 '15 at 16:22
  • Sorry I can't help. Maybe if you copy some of the security settings from sudo iwlist wlan0 scan, but I find it hard to believe anyone would run a network with no security. – Milliways Jan 19 '15 at 00:10
  • No worries. Post has been updated with the settings. – user2245766 Jan 19 '15 at 03:17