First, you can double-check your /etc/network/interfaces
file against mine:
auto lo
iface lo inet loopback
auto wlan2
iface wlan2 inet dhcp
wpa-ssid <my essid>
wpa-psk <my passphrase>
auto eth0
iface eth0 inet static
address <my static ip>
network <my local network>
netmask <my netmask>
(My ESSID and passphrase don't have spaces in them, so I don't know if you need quotes for such entries or not)
I think order of the interfaces matters. If you want to primarily use wifi, I think you need that first. Read more in man interfaces
.
If that looks good, you can run some in-depth troubleshooting:
You need three basic things for wifi networking: a connection, an IP address, and appropriate routing.
You can troubleshoot by running some command line operations to see if you can connect at all (independent of the /etc/network/interfaces
).
First reset everything
sudo killall wpa_supplicant
sudo ip link set <interface> down
sudo dhclient -r <interface>
Then start the process of making a connection:
# turn on the interface without auto-configuring:
sudo ip link set <interface> up
Make sure you can see the network in question:
# display wifi beacons being broadcast by nearby access points
sudo iwconfig <interface> scan
Configure and run wpa_supplicant:
# create a config file for wpa, use quotes if there's a space:
wpa_passphrase "<your ESSID>" "<your passphrase>" > ~/wpa.conf
# run wpa_supplicant on that config file, in the foreground
sudo wpa_supplicant -D wext -i <interface> -c ~/wpa.conf
The output of wpa_supplicant will help you troubleshoot the wifi connection. If it says it connects, you can either run the following commands in a new command prompt, or send wpa_supplicant to the background by pressing ctrl-z then running
# after pressing ctrl-z to pause the wpa_supplicant, run it in background
bg "%sudo"
Now run sudo iwconfig
to verify your connection, the parts like "ESSID:" and "Access Point:" should have values.
Your next step is to get an IP address from your router's DHCP server:
sudo dhclient <interface>
If you are connected to the network, this really shouldn't fail. If it does... maybe reset your router? Test if it worked properly by running sudo ifconfig
. Assuming you are using IPv4 addresses, you should see an IPv4 "inet addr:" that matches your router, likely a 10...* or a 192.168.1.* address.
dhclient
should also set your routing appropriately, so (in the absence of other network connections to the internet) sudo ip route
or sudo route
should have a "default" option that points to your wifi router on the <interface>
.
After that, you can test the connection to your local router:
ping <router's ip address>
Test if can connect to a remote ip address
ping 8.8.8.8 # google's dns server
Test if your DNS settings work:
ping google.com
If that works, you should be solid. If not, then you can change your /etc/resov.conf
file to read
nameserver 8.8.8.8
nameserver 8.8.4.4
Now, if you've verified that you can connect to the network with these steps, you may be able to use some of the same tools to troubleshoot the /etc/network/interfaces
approach.
I can help more if you share the output of sudo ifconfig
, sudo iwconfig
, sudo route
or sudo ip route
(sometimes when your connection is messed up, one or the other will hang), the relevant section of sudo iwlist <interface> scan
, the /etc/network/interfaces
file, and any relevant details from sudo dmesg
.