1

I've installed a fresh Ubuntu 16.04 server and can't get WIFI to work. My /etc/network/interfaces file looks like this:

auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet dhcp
wpa-ssid lomboboo
wpa-psk password

I also tried this setup as it was suggested in this answer:

auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet static
address 192.168.1.150
netmask 255.255.255.0
gateway 192.168.1.1
wpa-ssid lomboboo
wpa-psk password
dns-nameservers 8.8.8.8 192.168.1.1

But none of them work.

Also this is info from ifconfig enter image description here

P.S. Don't know if it matters - Ubuntu 16.04 server is running on Raspberry Pi 3.

EDITED sudo ifdown wlan0 && sudo ifup -v wlan0 output: enter image description here

ping -c3 8.8.8.8 output:

connect: Network is unreachable
lomboboo
  • 123

2 Answers2

6

I suspect that you have set wpa-psk in /etc/network/interfaces to the passphrase for your wireless network. That will not work.

Let's say the SSID for my router is MYROUTER, and I set the WPA/WPA2 passphrase on my router to MySecretPassphrase. At first glance, you would think that /etc/network/interfaces should look like this:

wpa-ssid MYROUTER
wpa-psk MySecretPassphrase

Wrong. I made this mistake a few months ago, and it took me a while to figure why it was not working. In short, wpa-psk should be set to the 256-bit pre-shared key for this SSID. Do not set wpa-psk to the passphrase.

How do you that? By using the wpa_passphrase command (if it isn't installed, you can install it with sudo apt install wpasupplicant). From the man page:

wpa_passphrase pre-computes PSK entries for network configuration blocks of a wpa_supplicant.conf file. An ASCII passphrase and SSID are used to generate a 256-bit PSK.

Let's give it a try:

~$ wpa_passphrase MYROUTER MySecretPassphrase

Output:

network={
    ssid="MYROUTER"
    #psk="MySecretPassphrase"
    psk=93763b13c803b7269956cb9bf584c75eb0fd0e99c51ecf49598a4016a29aa3f1
}

Assuming the wireless adapter is labeled wlan0, the /etc/network/interfaces file for the example above should look like this:

auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet dhcp
wpa-ssid MYROUTER
wpa-psk 93763b13c803b7269956cb9bf584c75eb0fd0e99c51ecf49598a4016a29aa3f1

Instead of typing this long string or using copy/paste, you can do this to append the relevant lines to /etc/network/interfaces:

~$ wpa_passphrase MYROUTER MySecretPassphrase | grep -vE "{|#|}" | tr -d '\t' | sudo tee -a /etc/network/interfaces

Then edit /etc/network/interfaces to make sure everything looks right.

Finally, either reboot or restart the networking service:

~$ sudo service networking restart
terdon
  • 100,812
0

For me

auto an_usb_interface
iface an_usb_interface inet dhcp

wpa-ssid MYROUTER wpa-psk MySecretPassphrase

was enough.

I answered this because the answer at this question is saying that this is wrong and to use the 256-bit pre-shared key for this SSID, but this is working (and cannot comment there yet; wpasupplicant is used at some point by /etc/init.d/networking start).

Sam
  • 65
  • 4