Connecting the wifi (and then connecting it again and again)
Once you’re connected to a wired network, getting the wifi working is the next task. First off, get very familiar with this file /etc/network/interfaces. Back it up first
sudo cp /etc/network/interfaces /etc/network/interfaces_backup
Try out the following commands, make sure you know the file inside and out.
sudo nano /etc/network/interfaces
Your file should look something like this:
iface lo inet loopback
iface eth0 inet dhcp
iface wlan0 inet manual
iface default inet dhcp
Just get really familiar with this file. You’re going to pull all your hair out over the weird disconnect issue That wireless-power off thing is really important I’ve seen quite a few forum threads, and help questions about weird disconnect issues that arise without it. In fact, you’re almost certain to run into this issue. Your wifi is going to drop and keep dropping, have patience. It could be anything even the dongle you picked. Heck, in my case it was both of those and my neighbor trying to hack my wifi (all at the same time).
There are instructions on putting the wifi username/password right into this the interfaces file, but it’s bad practice. As far as I can understand it’s harder to get access to /etc/wpa_supplicant/wpa_supplicant.conf than it is to get access to /etc/network/interfaces for some reason. I don’t really know, it just feels safer to keep the wifi info in the supplicant.conf file.
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
The wpa_supplicant.conf file should look something like this. Remember to use tabs instead of spaces for some reason?!? I don’t know why, but if you don’t use tabs instead of spaces on the bottom half of this file, it might just go crazy on you.
Be patient it won’t want to connect to the wifi right away. What I mean is, put the dongle in the raspberry pi while it’s still connected to the wired network. It always seems to need some kind of coaxing on it’s first attempt at connecting wirelessly. No matter what it always takes some prodding.
…will tell you if the dongle is recongized and plugged in.
…will show what is going on with the wifi.
If it says ‘unassociated’ it’s not connected yet then, this will scan the wifi in the local area.
sudo iwlist wlan0 scan
This may wake the sucker up.
sudo ifdown wlan0
sudo ifup wlan0
I really don’t know what to tell you here. The stuff is fickle maybe it’s a drivers issue, maybe its the power supply not supplying enough juice. It’s just going to suck your soul out to try to get this thing connected to wifi, oh okay there we have it… once iwconfig no longer says unassociated it should be working somewhat well. The choice between the wpa-roam option and wpa-conf function plays somewhat with the way that it works while connected into the wired.
As far as I can tell, the wpa-roam will connect with the router, but not register with the dhcp server if a wired connection is available. However, it will keep trying to reconnect when it finds no wired network. The wpa-conf option will not keep reconnecting which is better if your neighbor is running deauth attacks on your router, damn neighbor. Maybe it’s time to admit that you need a different power supply, or even a different wifi dongle. Play this game until you’re ready to move on.
More, wpa-roam and wpa-conf seem to work differently for different dongles, routers, or even network configurations. Once connected it should easily reconnect on boot. Dropped connections are usually due to bad dongles, bad routers, low power, low signal, neighbor deauth attacks, and all sorts of issues. Don’t expect to sidestep this whole debacle.