Wifi at boot
Some people may have noticed that wifi doesn’t exactly turn itself on until the user has logged in to the desktop. That’s a problem for some users. How is it a problem? It gets in the way of remote administration.
If I’m at work and am remotely logged in to my home PC (via SSH, for example) then there may come a time when I want to reset my PC. If my wireless does not turn itself on when the PC turns on then I end up with a PC turned on at home, not connected to the internet, and no one around to log in for me.
Note: In the following example, your wifi card may not be recognized as “wlan0”. Type “ifconfig” to see what yours may be. Substitute whatever yours is in place of wlan0.
How do you connect to a wireless access point from the command line?
First, you “turn on” your wireless card
sudo ifconfig wlan0 up
Now you should be able to
sudo iwlist wlan0 scan
which will show you all the wifi access points within range. The wifi card needs to know which access point to connect to. This is done by
sudo iwconfig wlan0 essid WhateverAPYouAreConnectingTo
and if it uses a (WEP) key then set the key
sudo iwconfig wlan0 key WhateverTheKeyIs
But you’re not connected yet. You need to establish the PC’s IP address within the network
sudo dhclient
and you’re set. You should see “bound to 192.168.x.x — renewal blah blah blah” as the last line. Test the connection
ping google.com
and you see that packets are being transmitted and received.
So how do you set that automatically? Stick the commands in your /etc/rc3.d/S99rc.local file, at the very bottom.
...blah blah... esac # Added on this date to get wifi on bootup ifconfig wlan0 up iwconfig wlan0 essid WhateverMyAccessPointIsCalled iwconfig wlan0 key WhateverMyKeyIs dhclient
Now every time you restart your computer, your computer will be connected to the network before you even log in.
Take a look at this article for some explanation of what rc.d scripts do.
[…] is. I hope this works for you as I wrote an explanation once upon a time for my own reference. http://n3wt0n.com/blog/?p=28 […]