I finally managed to make wlan0 (an Edimax EW-7811Un USB WiFi dongle) connect to my router, but after an apt-get update I discovered that the Raspberry can't see outside the local network. My Raspberry is running on the latest (as of writing this) Raspbian image.

  • wlan0 is connected to my router and has been given an IP address
  • I can ping my router, my printer, and other machines inside the local network, but I can't ping anything in the outside net (also loopback ping on localhost says "host unreachable", but I'd say that it is NAT cancelling requests)
  • I can successfully connect through eth0, but I need to connect through wlan0.

ifconfig output:

pi@MinoPi ~ $ ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr *macaddresshere*
      inet addr:  Bcast:  Mask:
      RX packets:552 errors:0 dropped:6 overruns:0 frame:0
      TX packets:289 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:375003 (366.2 KiB)  TX bytes:318051 (310.5 KiB)

iwconfig output:

pi@MinoPi ~ $ iwconfig wlan0
wlan0     IEEE 802.11bg  ESSID:"Sanctuary"  Nickname:"<WIFI@REALTEK>"
      Mode:Managed  Frequency:2.437 GHz  Access Point: *macaddresshere*
      Bit Rate:54 Mb/s   Sensitivity:0/0
      Retry:off   RTS thr:off   Fragment thr:off
      Power Management:off
      Link Quality=100/100  Signal level=100/100  Noise level=0/100
      Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
      Tx excessive retries:0  Invalid misc:0   Missed beacon:0

/etc/network/interfaces file:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

iface wlan0 inet static
    wpa-ssid "Sanctuary"
    wpa-psk "somePasswordHere"

Any ideas?


Problem solved! It seems that even though I added the gateway information into the interfaces file, wlan0 didn't really have a default gateway.

When I ran

sudo route -n

it yielded

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface   U     0      0        0 wlan0

There it is - no Gateway IP. I typed this:

 sudo route add default gw

(where is an IP address of my router, which is connected to the outside net)

Et voilà: it works.

  • 4
    Anyone got any clue as to why the gateway isn't being added automatically? – Endareth Jan 5 '16 at 3:47
  • You should add the IP of your router, not the IP of your machine. – Błażej Michalik Apr 3 '16 at 16:10
  • 3
    @Błażej Michalik, I am using Raspberry PI 3 operating system. The problem is in masking the gateway Ip address and * persisting it * across reboots. How would you propose to maskthe gateway Ip address and * persist it * across reboots? Thanks – Frank Aug 19 '16 at 14:31
  • @Frank Gateway IP is not masked, it is just an address, it's not a range of addresses. You have to add a gateway route to your routing tables. The masking of destination addresses is up to your local network setting. The route utility should add the address in a persistent way, but I think it is depreciated now, you can look up ip route (man ip). – Błażej Michalik Aug 20 '16 at 15:50
  • 1
    I am very much interested in the answer to @Endareth question - even more so in how to code a response for the raspberry pi to find and connect to a response automatically. If you give a raspberry pi as a gift to someone who doesn't know computers, it shouldn't stop operating immediately. – chase Mar 24 '17 at 17:36

protected by Community Mar 19 '15 at 16:06

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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