Friday, 24 May 2013

How to deploy Wireless Lan in a Centos 6.4 based Headless Computer

Deploy Wireless Lan in a  Centos 6.4 based Headless Computer

Objectives:

A. Deploy wireless LAN connectivity using WPA2 security on a system that does not run NetworkManager service.

B.  Follow Red Hat's principle to configuring networking:

"Do not use custom init scripts to configure network settings. When performing a post-boot network service restart, custom init scripts configuring network settings that are run outside of the network init script lead to unpredictable results."


1. Install firmware for wireless lan(wlan) adaptor of your notebook.

2. Check the wlan adaptor is working by using wireless tools

#yum install wireless-tools


#iwlist wlan0 scanning


(Extract of output)


wlan0     Scan completed :

         Cell 01 - Address: 00:1E:58:EA:71:93

                   Channel:1

                   Frequency:2.412 GHz (Channel 1)

                   Quality=59/70  Signal level=-51 dBm  

                   Encryption key:on
                   ESSID:"My Wireless Access Point"
                   Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s
                   Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s
                             36 Mb/s; 48 Mb/s; 54 Mb/s
                   Mode:Master

If output such as above is display, it indicates that the wlan adaptor is able to discover wireless access points.

3. Modify interface configuration scripts for wlan interface as root user

# cd /etc/sysconfig/network-scripts/

# ls -l ifcfg-wlan0
-rw-r--r--. 1 root root 274 May 22 21:30 ifcfg-wlan0

Add the following parameters to ifcfg-wlan0

#grep  "Wireless" -A 20 /usr/share/doc/initscripts-9.03.38/sysconfig.txt 
  Wireless-specific items:
    See iwconfig(8) for additional information.
    MODE=[Ad-Hoc|Managed|Master|Repeater|Secondary|Monitor|Auto]
    ESSID=
      Defaults to "any".
    NWID=
    FREQ=
      Ignored if MODE=Managed.
    CHANNEL=
      Ignored if MODE=Managed.
    SENS=<sensitivity threshold>
    RATE=
    KEY{1,2,3,4}=<WEP key with the given index> (Not needed)
    DEFAULTKEY=<default key index> (Not needed)
    KEY=<default WEP key> (Not needed)
    SECURITYMODE=[on|off|open|restricted]
    RTS=[auto|fixed|off|<rts threshold>]
    FRAG=[off|<fragmentation threshold>]
    IWCONFIG=<other iwconfig(8) options> (Not needed)
    SPYIPS=<list of IP addresses to monitor for link quality> (Not needed)
    IWPRIV=<iwpriv(8) commands> (Not needed)

An example of ifcfg-wlan0:

DEVICE=wlan0
HWADDR=00:1B:77:AC:DC:D2
TYPE=Ethernet
UUID=eef1e3e3-cc34-4651-8977-0810f12ef3a7
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
IPADDR=192.168.0.7
PREFIX=24
GATEWAY=192.168.0.1
MODE=Managed
ESSID="Majapahit Wayarles II"
RATE=auto
SECURITYMODE=on
RTS=auto
FRAG=auto


4. Install wpa_supplicant package

#yum install wpa-supplicant

5. Install dbus package

#yum install dbus

6. Modify wpa_supplicant.conf

#vi /etc/wpa_supplicant/wpa_supplicant.conf

Examples of a modified wpa_supplicant.conf:

network={
                    ssid="MYNETWORKSSID"
                    scan_ssid=1
                    key_mgmt=WPA-PSK
                    psk="MYNETWORKPSK"
}

7. Modify /etc/sysconfig/wpa_supplicant

Add wireless interface

Example:

INTERFACES="-iwlan0"

8. Start the following services

#service messagebus start

#service start wpa_supplicant

#service network restart

9. Check that wlan interface link status is up

#ip link show wlan0

Example Output:


2: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:1b:77:ac:dc:d2 brd ff:ff:ff:ff:ff:ff

10. Check ip address of wlan0 interface

#ip addr show wlan0

Example output
2: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:1b:77:ac:dc:d2 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.7/24 brd 192.168.0.255 scope global wlan0
    inet6 fe80::21b:77ff:feac:dcd2/64 scope link 
       valid_lft forever preferred_lft foreve



11. Configure the following services to run automatically  upon system starting up

#chkconfig --level 3 messagebus on

#chkconfig --level 3 wpa_supplicant on

12. Ensure the messagebus service starts first before wpa_supplicant service


# ls -l /etc/rc.d/rc3.d/ | grep messagebus && ls -l /etc/rc.d/rc3.d/ | grep wpa_supplicant
lrwxrwxrwx. 1 root root 20 May 22 11:46 S22messagebus -> ../init.d/messagebus
lrwxrwxrwx. 1 root root 24 May 22 12:19 S23wpa_supplicant -> ../init.d/wpa_supplicant

The XX number in SXXmessagebus of messagebus service must be less than YY number in SYYwpa_supplicant of wpa_supplicant service

------------------------------------THE END------------------------------------------------

Other sources that I referred to:

http://wiki.centos.org/HowTos/Laptops/WpaSupplicant

http://minimallinux.blogspot.sg/2012/06/centos-6-wireless.html



No comments:

Post a Comment