Linux Wireless Networking Setup on a Desktop Machine
I have a desktop machine that doesn’t move and will only need to connect to my home network. Even though it’s a pretty new machine and could handle it easy enough, I didn’t want the overhead of a network manager running all the time.
Assuming you use wpa, you’ll need to learn how to manually connect to your wireless network using wpa_supplicant and wpa_supplicant.conf (don’t worry, we’ll automate this in a minute).
My setup is pretty typical I think so here’s what my wpa_supplicant.conf looks like.
network={
ssid=”networkname”
psk=”secretpassphrase”
}
After you make wpa_supplicant.conf, you’re ready to start setting up your connection. Here are the commands I use to do that.
wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf
After running that, you probably still need an IP address if you’re using dhcp (as most people do). Arch Linux uses dhcpcd but it seems like most other distros I’ve used have dhclient installed. Anyway, on my system I use this to get an IP address from my wireless router.
dhcpcd wlan0
If you want, you could just do these things every time you boot but it’s also pretty easy to automate so you can have networking start at boot time with no pesky daemons that you don’t need running all the time. Arch uses a file called /etc/rc.local. You can put commands in this file and they’ll run at boot time but since the system isn’t fully up and $PATH may not work correctly yet, you’ll want to modify those earlier commands just a little. The locations of these commands can vary by distro but in Arch, here’s my rc.local file.
/usr/sbin/wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf
sleep 2
/usr/sbin/dhcpcd wlan0
Notice these are the same commands we used to manually set up the connection but with the full path to the command inserted. Also, the sleep 2 line pauses 2 seconds just to make sure the association is complete before the machine tries to get an IP address.
That’s all there is to it. Keep in mind, if you’re not using Arch this exact procedure will not work for you but the basic idea could be used if you want.