Wednesday, April 2, 2014

Setup Wifi for Ubuntu Server without Cable Connection

For the first time, try to install Ubuntu Server 12.04 on an idle notebook, but found it is a lot of trouble to setup the wifi network without cable connection.

Step 1: First thing to check,
$ iwconfig
you should expect to see "wlan0" in the list. If not, it means there is something missing. In my case, the Ubuntu Server doesn't come with the wifi card driver for my PC.

Step 2: Use lspci command to find your network controller.
$ lspci 
......
04:00.0 Network controller: Broadcom Corporation BCM4312 802.11b/g LP-PHY (rev 01)
......
In my cast, it is BCM4312.

Step 3: Go to find the corresponding driver package(.deb file) and download on a computer that has network connection.
Step 4: Without cable connection, you can use the USB stick to transfer the driver installation package. Using mount command to help you out. More details here
//Create the Mount Point(a directory, e.g. usb)
$ sudo mkdir /media/usb
//Find your usb device, something like /dev/sdb1
$ sudo fdisk -l
//Assume your device is /dev/sdb1, the filesystem is FAT16 or FAT32
$ sudo mount -t vfat /dev/sdb1 /media/usb -o uid=1000,gid=1000,utf8,dmask=027,fmask=137
Now go to the mount directory and copy package to local disk.
//copy file from usb directory to local
$ sudo cp /media/usb/package_name.deb /local_path 
Then unmount the usb device.
//unmount your device
$ sudo umount /media/usb

Step 5: Install driver.
//go to the package file directory and install
$ sudo dpkg -i package_name.deb
After reboot you should see the wlan0 in your iwconfig list.

Step 6: Edit your network interfaces file under /etc/network and set up the static IP address (so you can reach it by ssh or ftp). A detailed explanation for each field can be found here
$ vi interfaces
Basically, you need to set up following info:
auto wlan0
iface wlan0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1 8.8.8.8
wpa-ssid <your_network>
wpa-psk <your_hex_key>
You need to get your paraphrased key for wpa-psk field via command: 
wpa_passphrase your_essid your_ascii_key
For example,
$ wpa_passphrase "mywifi" "123123123"
network={
 ssid="mywifi"
 #psk="123123123"
 psk=6300c5dc74f4634edb78d8abd42903d87e2da04d1d4ac4d7843f542fa4d61d91
}
The hex key generated here is what you need to provide for wpa-psk field. 

Step 7: Now restart network and test your network connectivity using ping.
$ sudo /etc/init.d/networking restart

No comments:

Post a Comment