How to install USB wireless NIC on Linux

Here are some lessons learned.

1. I am using a RTL8187 chipset
2. It’s usb
3. It’s being installed on CentOS 5.6
4. I am trying to connect to an OPEN SSID

Here are the steps I had to do… hope it helps.

Run ‘iwconfig’ and make sure wlan0 is listed.

# iwconfig 
lo        no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:"NETWORKSSID"  
          Mode:Managed  Frequency:2.462 GHz  Access Point: 68:7F:74:AD:F3:3C   
          Bit Rate=54 Mb/s   Tx-Power=16 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          Link Quality=50/70  Signal level=-60 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:90   Missed beacon:0

Create an ifcfg file for this interface by copying ifcfg-eth0 and naming it ifcfg-wlan0, because it doesn’t show up in ifconfig.

cp /etc sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-wlan0

Edit the ifcfg for this interface. For example, using wlan0.

vi /etc/sysconfig/network-scripts/ifcfg-wlan0

Change it to look like this

DEVICE=wlan0
BOOTPROTO=dhcp
DHCPCLASS=
#HWADDR=00:1A:A0:D4:79:53
IPV6INIT=yes
IPV6_AUTOCONF=yes
ONBOOT=yes
less /etc/sysconfig/wpa_supplicant

Ensure that your device is included in the INTERFACES line in this file.

In this example wlan0 is the only device supported by wpasupplicant.

# Use the flag "-i" before each of your interfaces, like so:
#  INTERFACES="-ieth1 -iwlan0"
INTERFACES="-iwlan0"
Edit /etc/wpa_supplicant/wpa_supplicant.conf

Here is an example of a network which doesn’t require a Pre Shared Key. If this appears before the “any” network it will be preferred to other open networks.

network={
        ssid="PUBLIC"
        key_mgmt=NONE
}

Create /etc/rc5.d/S09prepnet

Paste the following text to create a new file which will prepare the running services for a wifi connection.

cat > /etc/init.d/prepnet <<EoT
#!/bin/sh

/etc/init.d/messagebus start
/etc/init.d/wpa_supplicant start
killall dhclient >/dev/null 2>&1
EoT
chmod a+rx /etc/init.d/prepnet
ln -s /etc/init.d/prepnet /etc/rc3.d/S09prepnet
ln -s /etc/init.d/prepnet /etc/rc5.d/S09prepnet

Configure services to run at boot

Paste the following commands to configure services.

chkconfig messagebus off
chkconfig wpa_supplicant off
chkconfig NetworkManager off
chkconfig network on

Finally Reboot

After the reboot… it should work… in my case it didn’t… I wasn’t getting an IP address. I had to perform one last step.

Enable DHCP for WLAN0

dhclient wlan0

That should be all she wrote!

wlan0 Link encap:Ethernet HWaddr 00:C0:CA:50:87:76 
 inet addr:10.180.1.194 Bcast:10.180.1.255 Mask:255.255.254.0
 inet6 addr: fe80::2c0:caff:fe50:8776/64 Scope:Link
 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
 RX packets:4094 errors:0 dropped:0 overruns:0 frame:0
 TX packets:5450 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:10000 
 RX bytes:1381678 (1.3 MiB) TX bytes:532421 (519.9 KiB)

About Daniel Fredrick

Technology enthusiast, Programmer, Network Engineer CCIE# 17094

View all posts by Daniel Fredrick →

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.