Centos 6/RHEL install and configure WPA2 wireless with NetworkManager & Fluxbox

Using your Centos 6/RHEL box with a wireless WPA2 configuration is pretty straightforward as the kernel supports a wide range of devices and the simplicity of a Fluxbox setup makes using NetworkManager to manage it a formality. So we take a look at installing and setting up a wireless connection for the Centos 6 Minimal Fluxbox Desktop using a Static IP, after setting the Router encryption to WPA2 and the passphrase of your choice, this being a commonly used configuration. It assumes you are using a Fluxbox Desktop, which does not ship with any networking tools, unlike the Gnome and KDE Desktops, however it is not really a problem at all to set up a network management interface in Fluxbox. 


Centos 6 WPA2 in Fluxbox


This method is for WPA2 using a static IP

You will need
The procedure is as follows, this assumes that you actually have installed a driver for your pci/usb wireless device and that it is detected by your OS. Your system may call wlan0 something else, likewise with an eth0 device.

Get dependencies

$ sudo yum -y install wireless-tools NetworkManager NetworkManager-gnome iproute


Check your network

$ sudo ifconfig -a              



Centos 6 ifconfig -a command
If wlan0 is not showing then there is a problem with your drivers and you cannot proceed. Try  http://linuxwireless.org/en/users/Drivers/ to see if there is one for your device. 

You can also use lsmod

$ lsmod | less

Scroll down with up/down arrows to see if it shows up.

Additionally, you can use getinfo if you install it.

$ getinfo.sh network

Set up the router.

Set up your router with a WPA2 encryption key/passphrase.


You can give it a hex key or asci (string) which may be converted by the router  to hex, some routers don't give you the converted key back in which case get a calculator that will convert a string to hex if you need to, or use the online converter below, and get the value that way. Individual routers will differ as to which is accepted. Here we use a string.

Use the online converter if necessary.


Building the ifcfg-wlan0 file


We will write a configuration file called ifcfg-wlan0 in /etc/sysconfig/network-scripts/ it should look similar to below:


TYPE=Wireless
DEVICE=wlan0         
BOOTPROTO=static
DHCPCLASS=
IPADDR=192.168.0.100
BROADCAST=192.168.0.255
HWADDR=48:02:2a:91:63:90
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
ONBOOT=no
ONHOTPLUG=yes
PEERDNS=no
USERCTL=yes
IPV6INIT=no
ESSID=minimallinux
CHANNEL=6
MODE=Managed
RATE=150Mb/s


Alter yours to suit your configuration, assigning a static IP from the range your router has available. We do not need a keys file as the key is entered into the NM Applet.

Now issue the dmesg command to obtain MAC/HWADDR

$ dmesg 


Or if you already have a ifcfg-wlan0 file

$ sudo grep wlan0 /var/log/dmesg
(you'll probably have to unplug and replug your device, especially usb)

****************************************************************
Look for 'ADDRCONF(NETDEV_UP): wlan0: link is not ready' and  'MAC Address = 48:02:2a:91:63:90

OR similar to

usb 1-7: New USB device found, idVendor=0bda, idProduct=8176

then further down the output

EEPROMVID = 0x0bda
EEPROMPID = 0x8176


_ReadMACAddress MAC Address from EFUSE = 48:02:2a:91:63:90

****************************************************************

which tells you that your device is detected and has a MAC Address of 48:02:2a:91:63:90 (which you will need for your ifcfg-wlan0 file, that is the HWADDR)

Now build the ifcfg-wlan0 config file


$ sudo vi /etc/sysconfig/network-scripts/ifcfg-wlan0 and enter the above with the appropriate alterations to suit your system.


See Vim Editor for vi commands 


You should also be able to get the BROADCAST, NETMASK and HWADDR entries from the 'ifconfig -a' command


Once the config file is in place with the correct details, open up the ~/.fluxbox/startup file with vi to enter the following


$ sudo vi ~/.fluxbox/startup


Centos 6 Fluxbox startup file
Enter in to it as below, before the 'exec fluxbox' line

/usr/bin/nm-applet &

Making sure to include the final '&' sign.

This is to ensure that the NM Applet shows in the Fluxbox tray.

Save and close the file.

You will probably want to disable the network and wpa_supplicant services at boot as NetworkManager will now take care of these.

# chkconfig network off

# chkconfig wpa_supplicant off


Now issue the commands to ensure that NetworkManager is 
started automatically as a service on boot 
and also so that it can be used immediately without rebooting. 

# chkconfig NetworkManager on

# service NetworkManager start

You should see the tray appear bottom right as below.


Centos 6 start NetworkManager
We do not need to use commands like ifconfig eth0 down etc because everything is now handled by the NM Applet. Obviously you should disable the eth0 connection in the applet if you are going to run a wireless connection. Right click and edit to see the connections, left click for others.


Cento 6 NetworkManager
The request for the keyring password, when using NetworkManager, can be suppressed by using the pam_keyring package. The pam_keyring package can be obtained from the RPMForge repo

So, a straighforward set up of a network management interface in a Centos Minimal Fluxbox system.

















Labels: , ,