Friday, September 01, 2006

Activate Fedora WiFi on Startup

For a while I have to use system-config-network to manually enable WiFi after each startup for Fedora. This is not only tedious, but keeps me from running netowrk-related stuff automatically on startup.

I searched around and found a post saying the following:
check if you have the file:
/etc/sysconfig/network-scripts/ifcfg-wlan0

If you don't, create it as follows:

DEVICE=wlan
BOOTPROTO=dhcp
ONBOOT=yes
ESSID=linksys

and try:
service network restart.

You might need to add some more parameters to /ifcfg-wlan0 for it to work, you can look them up in /etc/sysconfig/network-scripts/ifup-wire
less.
I looked at my system and there is a similar file:
/etc/sysconfig/network-scripts/ifcfg-dev12174
It is the one related to my current wireless setup. As I remember every time I use system-config-network to manually activate WiFi, dev12174 is the one.

I saved the original file and edited the content by changing the following line:
ONBOOT=yes
After reboot, WiFi is automatically activated :)

The new /etc/sysconfig/network-scripts/ifcfg-dev12174 file looks like:
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
IPV6INIT=no
ONBOOT=yes
USERCTL=no
PEERDNS=yes
GATEWAY=
TYPE=Wireless
DEVICE=dev0
HWADDR=hh:hh:hh:hh:hh:hh
BOOTPROTO=dhcp
NETMASK=
DHCP_HOSTNAME=
IPADDR=
DOMAIN=
ESSID=
CHANNEL=6
MODE=Auto
RATE='11 Mb/s'

I also came acroos this suggestion below. I did not use it though:
make a new file 'wifi' in your /etc/init.d directory (chmod 755 it) and edit it:

#!/bin/sh
case "$1" in
start)
echo -n "Starting WIFI Network"
iwconfig wlan0 essid "linksys"
dhclient wlan0
echo "."
;;
stop)
echo -n "Stopping WIFI Network"
ifdown wlan0
echo "."
;;
restart)
echo -n "Restarting WIFI Network"
ifdown wlan0
iwconfig wlan0 essid "linksys"
dhclient wlan0
echo "."
;;
*)
echo "Usage: /etc/init.d/wifi {start|stop|restart}"
exit 1
;;
esac

exit 0

then, make a link to this file in the appropriate runlevel directory to get it started (let's put in in runlevel2, this is the first multiuser runleve)
ln -s /etc/init.d/wifi /etc/rc2.d/SS15wifi

this should do.
if you have to restart your wifi for some reason, you can type: /etc/init.d/wifi restart

No comments: