39

I just installed Ubuntu 14.04 Server and cannot get wifi configured correctly to work with WPA2 personal and could use some help.

There was a simple wizard during install where I selected my SSID from a list and entered my passphrase and that worked great. Now that the install is done I am having trouble configuring wifi. My Access Point is setup to WPA2 Personal TKIP or AES. Any advice would be greatly appreciated. I have been messing around with WPA supplicant ant my /etc/network/interfaces file with no luck.

Thanks

clettsome
  • 493

5 Answers5

56

I suggest you set up /etc/network/interfaces something like:

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 <your_router>
wpa-psk <your_wpa_key>
dns-nameservers 8.8.8.8 192.168.1.1

Be sure to select a static address outside the range used by the DHCP server in the router, switch or other access point. Of course, substitute your details here.

Get the system to read and use the changes:

sudo ifdown wlan0 && sudo ifup -v wlan0

Did you connect?

ping -c3 192.168.1.1
ping -c3 www.google.com
chili555
  • 61,330
33

I managed to connect to my WPA2 access point by putting the following in /etc/network/interfaces. Slightly modified from the accepted answer, and using DHCP.

auto wlan0
iface wlan0 inet dhcp
wpa-ssid <your_router>
wpa-psk <your_wpa_key>

Then a simple sudo ifup -v wlan0 and it connected. All good.

phocks
  • 462
3

Using either DHCP or a static config (doesn't matter which)--AND assuming your wifi worked during install--make your /etc/network/interfaces look something like below (for wlan0 should match the name of your wifi card listed under ifconfig -a e.g. your detected wifi card could be nicknamed eth1 by the OS for all I know.):

 auto lo iface lo inet loopback     
 auto wlan0 iface wlan0 inet dhcp    
 wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

To configure wpa_supplicant use the command (Referenced in the config above)

wpa_passphrase "YOUR_SSID" SSID_PASSWORD | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf

Next, create a new executable script named iwconfig (you can name this script anything really, "iwconfig-default-ssid", perhaps?--I just made it short for the example):

sudo touch /etc/network/if-up.d/iwconfig && sudo chmod 700
/etc/network/if-up.d/iwconfig && sudo ln -s
/etc/network/if-up.d/iwconfig /etc/network/if-pre-up.d/iwconfig

Now edit /etc/network/if-up.d/iwconfig and add the SSID you want Ubuntu Server to connect to on startup:

#!/bin/sh
iwconfig wlan0 essid "YOUR_DEFAULT_SSID" mode managed

Now bring ifdown (if you haven't already), then ifup, and you should be golden now and when you reboot (as long as you're near your SSID.)


If you're out in public with your laptop with this config, you'll have to use: iwlist wlan0 scan, then sudo iwconfig essid "PUBLIC_ESSID" mode managed to connect with anything (and/or make a unique script for each place(s) you visit--just don't put any of these scripts under the 'if-up.rc.d' folder. /etc/network/interfaces can also handle location alias, so check the man/forums for help on this.)

Or you can try your luck with the CLI frontend for wicd when roaming about town:

sudo apt-get install wicd-curses

andyc
  • 3
  • 2
1

Perhaps you could try using Network Manager or Wicd. While Network Manager does have a few GUI dependencies which you might dislike having on a headless server, connecting to wifi is quite simple. For a hotspot setup by my Android phone (called Android AP), I could connect using:

nmcli dev wifi connect 'Android AP' password test

You might find WICD more useful, as curses-based interface as well (http://manpages.ubuntu.com/manpages/lucid/man8/wicd-curses.8.html). I haven't used it much, so I am not sure of the syntax for connecting to wifi.

If /etc/network/interfaces is your only option, maybe you could show what you have done so far to see how we might fix it.

muru
  • 207,228
0

A real good super easy way to set up WiFi on the command line is with nmtui but I can't find how to install it.

0xF2
  • 3,155