How to set up a WPA2 wireless connection in Fedora using the ifcfg method

view full story

http://forums.fedoraforum.org – NetworkManager is a powerful tool for setting up a wlan connection, especially if you connect the laptop to multiple access points. One drawback is that the user accounts must be given access to the pass phrase. Another is that there is no wlan connection in run level 3, because nm-applet is an X application. If you connect to the same access point all the time, e.g., your own wireless router, a permanent connection via ifcfg might be more convenient. It is controlled by root. All user accounts have wireless access without knowing the underlying details. Further, there is a wireless connection in run level 3. After a lot of trial and error and Google searches, I was able to put together this guide by splicing together one step used in Slackware (from Alienbob's web page) with other steps outlined in this online article http://home.roadrunner.com/~computer...hwireless.html. It is assumed that the appropriate kernel module for the wlan card is installed and that $ iwconfig shows a viable wlan0 interface. We are using DHCP. (If using static IP, edit ifcfg-wlan0.) The following steps work on a Compaq Presario F756NR notebook with a Atheros AR242x 802.11abg WLAN card using the ath5k kernel module (without madwifi). I am using 64-bit F12. All commands are executed as root. 1. $ yum install wpa_supplicant dhclient Probably already installed, especially dhclient. If so, skip. 2. $ cd /etc/sysconfig && vi wpa_supplicant Insert the following lines: INTERFACES="-iwlan0" DRIVERS="-Dwext" OTHER_ARGS="-f /var/log/wpa_supplicant.log" I usually comment out OTHER_ARGS. It creates a large log file I don't need. 3. $ cd /etc/wpa_supplicant && vi wpa_supplicant.conf Insert the following lines, where Your_SSID is obvious and Your_PSK will be generated in step 4: ctrl_interface=/var/run/wpa_supplicant ctrl_interface_group=0 eapol_version=1 ap_scan=1 fast_reauth=1 network={ # Set scan_ssid=1 if the access point is hidden. scan_ssid=0 proto=WPA RSN key_mgmt=WPA-PSK pairwise=CCMP TKIP group=CCMP TKIP WEP104 WEP40 ssid="Your_SSID" psk=Your_PSK } 4. $ wpa_passphrase Your_SSID Your_wpa2passphrase >> wpa_supplicant.conf No quotes. 5. $ vi wpa_supplicant.conf There should now be a new "network" code block at the end of wpa_supplicant.conf. Copy the new SSID and PSK lines to the "network" block above at the locations shown in step 3. Delete the new "network" code block. 6. $ chmod 600 wpa_supplicant.conf 7. $ cd /etc/sysconfig/network-scripts && vi ifcfg-wlan0 Insert the following lines: DEVICE=wlan0 ONBOOT=no TYPE=Wireless BOOTPROTO=dhcp 8. $ service NetworkManager stop ; chkconfig NetworkManager off 9. $ service wpa_supplicant start ; chkconfig wpa_supplicant on 10. $ service network stop It is probably stopped anyway. network and NetworkManager are mutually exclusive. (Optionally, set $ chkconfig network on in case you need to use a wired Ethernet connection in the future. It has no impact on the wireless steps here.) 11. If you had set ONBOOT=yes in ifcfg-wlan0, you could start the wlan connection now using $ service network start You might want to try this now to test the connection. Intuitively, you would expect that if you were to set $ chkconfig network on you would have a wireless connection on reboot. Unfortunately, this is not the case. This is because Fedora starts network before wpa_supplicant. One solution would be to change the order of the startup scripts by renaming the wpa startup script, giving it a lower S-number. Another solution would be to change the chkconfig priorities by editing /etc/rc.d/init.d/wpa_supplicant. But a yum update might reset all of this. So we use another method. 12. Set ONBOOT=no in ifcfg-wlan0. 13. $ cd /etc/rc.d && vi rc.local Insert the following lines: /bin/sleep 1 /sbin/dhclient wlan0 On reboot, the wireless connection should be established. (HowTos)