Difference between revisions of "Wireless from the Terminal"
(cat) |
(formating) |
||
Line 1: | Line 1: | ||
− | Sometimes, you may wish to bypass network manager and configure the WLAN directly. Here is described how to do this. | + | Sometimes, you may wish to bypass network manager and configure the [[WLAN]] directly. Here is described how to do this. |
===Becoming Root=== | ===Becoming Root=== | ||
* You'll need to be root for pretty much everything here. | * You'll need to be root for pretty much everything here. | ||
− | + | <source lang="bash">sudo -i</source> | |
===Killing NetworkManager=== | ===Killing NetworkManager=== | ||
* A good first step is to just stop NetworkManager, so it doesn't conflict with what we're doing now. | * A good first step is to just stop NetworkManager, so it doesn't conflict with what we're doing now. | ||
− | + | <source lang="bash">/etc/init.d/NetworkManager stop</source> | |
===Optional: Disabling NetworkManager=== | ===Optional: Disabling NetworkManager=== | ||
Line 14: | Line 14: | ||
* This will remove NetworkManager from startup. | * This will remove NetworkManager from startup. | ||
− | + | <source lang="bash">update-rc.d -f NetworkManager remove</source> | |
* This will add it back. | * This will add it back. | ||
− | + | <source lang="bash">update-rc.d NetworkManager defaults</source> | |
===Configuring wpa_supplicant=== | ===Configuring wpa_supplicant=== | ||
Line 22: | Line 22: | ||
* Anyway, wpa_supplicant needs to be configured. It's default config file is found in /etc/wpa_supplicant.conf. Here's a basic configuration file that should work with most home routers with WPA. If you have no encryption, set key_mgmt to NONE and remove the psk= line. If you have WEP, key_mgmt should also be NONE and psk= should be removed and replaced with wep_key0= followed by the HEXADECIMAL wep key. You'll need some kind of converter to go from an ASCII key to a HEX key. Here's one, be safe and make sure you don't use the key for anything else important, since you're entering it in to another site: [http://www.speedguide.net/wlan_key.php WEP key converter] | * Anyway, wpa_supplicant needs to be configured. It's default config file is found in /etc/wpa_supplicant.conf. Here's a basic configuration file that should work with most home routers with WPA. If you have no encryption, set key_mgmt to NONE and remove the psk= line. If you have WEP, key_mgmt should also be NONE and psk= should be removed and replaced with wep_key0= followed by the HEXADECIMAL wep key. You'll need some kind of converter to go from an ASCII key to a HEX key. Here's one, be safe and make sure you don't use the key for anything else important, since you're entering it in to another site: [http://www.speedguide.net/wlan_key.php WEP key converter] | ||
+ | <source lang="apache"> | ||
network={ | network={ | ||
	ssid="Access Point SSID goes here" | 	ssid="Access Point SSID goes here" | ||
Line 28: | Line 29: | ||
	psk="password goes here" | 	psk="password goes here" | ||
} | } | ||
+ | </source> | ||
* A good idea now would be to reboot, to make sure everything is clean. You may need to kill NetworkManager again afterwards, then toggle WLAN off then on (Menu -> System -> Toggle WiFi). You can also make wpa_supplicant reload it's configuration without rebooting: | * A good idea now would be to reboot, to make sure everything is clean. You may need to kill NetworkManager again afterwards, then toggle WLAN off then on (Menu -> System -> Toggle WiFi). You can also make wpa_supplicant reload it's configuration without rebooting: | ||
− | + | <source lang="bash">wpa_cli</source> | |
* Then type at the prompt | * Then type at the prompt | ||
− | + | <source lang="bash">reconfigure</source> | |
wpa_cli is also good to check the status of wpa_supplicant when you're trying to connect. It'll spit out messages based on what's going on while you're toggling WLAN on and off to see if it's associated or just times out. | wpa_cli is also good to check the status of wpa_supplicant when you're trying to connect. It'll spit out messages based on what's going on while you're toggling WLAN on and off to see if it's associated or just times out. | ||
If wpa_cli outputs "Could not connect to wpa_supplicant - retrying" you need to enable WLAN via "Main Menu"->"System"->"Toggle WiFi" first. | If wpa_cli outputs "Could not connect to wpa_supplicant - retrying" you need to enable WLAN via "Main Menu"->"System"->"Toggle WiFi" first. | ||
+ | |||
===Setting Up the Network=== | ===Setting Up the Network=== | ||
Once you have a connection to the access point, you need to set up a few things either manually or through DHCP. | Once you have a connection to the access point, you need to set up a few things either manually or through DHCP. | ||
* To check for connection, if you have wpa_cli running, you can see it's output when you're toggling WLAN on. It'll either say it's Associated, which means it succeeded or that it's timed out, which means it failed, or possibly any other number of errors. You can also check iwconfig. | * To check for connection, if you have wpa_cli running, you can see it's output when you're toggling WLAN on. It'll either say it's Associated, which means it succeeded or that it's timed out, which means it failed, or possibly any other number of errors. You can also check iwconfig. | ||
− | + | <source lang="bash">iwconfig</source> | |
* If it says Access Point:Not-Associated after about 30 seconds, that means it has likely failed. If you see a 12 digit hex string, that means it has found the access point and has an active connection to it. | * If it says Access Point:Not-Associated after about 30 seconds, that means it has likely failed. If you see a 12 digit hex string, that means it has found the access point and has an active connection to it. | ||
====Automatic==== | ====Automatic==== | ||
* If you trust DHCP to work, you can just try this. | * If you trust DHCP to work, you can just try this. | ||
− | + | <source lang="bash">udhcpc -i wlan0</source> | |
If all goes well, everything will be properly configured and you'll be on the net. Otherwise you should try to do it manually (see below). | If all goes well, everything will be properly configured and you'll be on the net. Otherwise you should try to do it manually (see below). | ||
Line 53: | Line 56: | ||
* This is optional, but I put it anyway, just in case it causes some kind of trouble. | * This is optional, but I put it anyway, just in case it causes some kind of trouble. | ||
− | + | <source lang="bash">ifconfig usb0 down</source> | |
* This disables power management, which can help a dodgy WLAN connection. | * This disables power management, which can help a dodgy WLAN connection. | ||
− | + | <source lang="bash">iwconfig wlan0 power off</source> | |
* This limits the rate to 11Mbit, which also can help an unstable WLAN connection. | * This limits the rate to 11Mbit, which also can help an unstable WLAN connection. | ||
− | + | <source lang="bash">iwconfig wlan0 rate 11M auto</source> | |
* Set the IP, broadcast and netmask all at once. | * Set the IP, broadcast and netmask all at once. | ||
− | + | <source lang="bash">ifconfig wlan0 192.168.1.150/24</source> | |
* If your network is weird, here's an alternate, more specific line. | * If your network is weird, here's an alternate, more specific line. | ||
− | + | <source lang="bash">ifconfig wlan0 192.168.1.150 broadcast 192.168.1.255 netmask 255.255.255.0</source> | |
* Add the route to the gateway. | * Add the route to the gateway. | ||
− | + | <source lang="bash">route add default gw 192.168.1.1</source> | |
Replace 192.168.1.1 with your gateway IP (You can get this from one of your other computers on the network. Linux: ifconfig Windows: ipconfig /all) and 192.168.1.150 with the IP you'd like your Pandora to be. There are a few caveats here, though. Simply put, the subnet needs to be the same as your gateway's subnet. So if it's 192.168.X.Y, it needs to start with 192.168.X or if it's 10.0.0.1, it needs to start with 10. Also for 10.0.0.1, the /24 needs to be /8. There's a bunch of other stuff to do with that, and many odd variations on it, but I'm sure there's a better reference for it elsewhere. | Replace 192.168.1.1 with your gateway IP (You can get this from one of your other computers on the network. Linux: ifconfig Windows: ipconfig /all) and 192.168.1.150 with the IP you'd like your Pandora to be. There are a few caveats here, though. Simply put, the subnet needs to be the same as your gateway's subnet. So if it's 192.168.X.Y, it needs to start with 192.168.X or if it's 10.0.0.1, it needs to start with 10. Also for 10.0.0.1, the /24 needs to be /8. There's a bunch of other stuff to do with that, and many odd variations on it, but I'm sure there's a better reference for it elsewhere. | ||
Line 69: | Line 72: | ||
* One last thing you'll need to do is set up DNS name servers. You can get this information from another computer on the network with a working Internet connection. | * One last thing you'll need to do is set up DNS name servers. You can get this information from another computer on the network with a working Internet connection. | ||
=====Linux===== | =====Linux===== | ||
− | + | <source lang="bash">cat /etc/resolv.conf</source> | |
* Copy that file verbatim in to the /etc/resolv.conf on the Pandora. | * Copy that file verbatim in to the /etc/resolv.conf on the Pandora. | ||
=====Windows===== | =====Windows===== | ||
− | + | <source lang="bash">ipconfig /all</source> | |
* There should be a line for Primary DNS Server and possibly Secondary DNS Server. They should be entered in to /etc/resolv.conf like this. | * There should be a line for Primary DNS Server and possibly Secondary DNS Server. They should be entered in to /etc/resolv.conf like this. | ||
+ | <source lang="bash"> | ||
nameserver Primary.DNS.Server.IP | nameserver Primary.DNS.Server.IP | ||
nameserver Secondary.DNS.Server.IP | nameserver Secondary.DNS.Server.IP | ||
− | + | </source> | |
If there is no secondary DNS server, don't worry, just enter only the first line, then. | If there is no secondary DNS server, don't worry, just enter only the first line, then. | ||
Revision as of 06:48, 24 April 2011
Sometimes, you may wish to bypass network manager and configure the WLAN directly. Here is described how to do this.
Contents
Becoming Root
- You'll need to be root for pretty much everything here.
sudo -i
Killing NetworkManager
- A good first step is to just stop NetworkManager, so it doesn't conflict with what we're doing now.
/etc/init.d/NetworkManager stop
Optional: Disabling NetworkManager
You may want to completely disable NetworkManager. Here's how.
- This will remove NetworkManager from startup.
update-rc.d -f NetworkManager remove
- This will add it back.
update-rc.d NetworkManager defaults
Configuring wpa_supplicant
wpa_supplicant is generally used for connecting using WPA, but I find it pretty convenient even on it's own. It'll also be easier to explain for 1 thing rather than explaining this and iwconfig. It also seems to start by default with the Pandora, but I honestly can't determine what starts it, just that it does.
- Anyway, wpa_supplicant needs to be configured. It's default config file is found in /etc/wpa_supplicant.conf. Here's a basic configuration file that should work with most home routers with WPA. If you have no encryption, set key_mgmt to NONE and remove the psk= line. If you have WEP, key_mgmt should also be NONE and psk= should be removed and replaced with wep_key0= followed by the HEXADECIMAL wep key. You'll need some kind of converter to go from an ASCII key to a HEX key. Here's one, be safe and make sure you don't use the key for anything else important, since you're entering it in to another site: WEP key converter
network={
	ssid="Access Point SSID goes here"
	scan_ssid=1
	key_mgmt=WPA-PSK
	psk="password goes here"
}
- A good idea now would be to reboot, to make sure everything is clean. You may need to kill NetworkManager again afterwards, then toggle WLAN off then on (Menu -> System -> Toggle WiFi). You can also make wpa_supplicant reload it's configuration without rebooting:
wpa_cli
- Then type at the prompt
reconfigure
wpa_cli is also good to check the status of wpa_supplicant when you're trying to connect. It'll spit out messages based on what's going on while you're toggling WLAN on and off to see if it's associated or just times out. If wpa_cli outputs "Could not connect to wpa_supplicant - retrying" you need to enable WLAN via "Main Menu"->"System"->"Toggle WiFi" first.
Setting Up the Network
Once you have a connection to the access point, you need to set up a few things either manually or through DHCP.
- To check for connection, if you have wpa_cli running, you can see it's output when you're toggling WLAN on. It'll either say it's Associated, which means it succeeded or that it's timed out, which means it failed, or possibly any other number of errors. You can also check iwconfig.
iwconfig
- If it says Access Point:Not-Associated after about 30 seconds, that means it has likely failed. If you see a 12 digit hex string, that means it has found the access point and has an active connection to it.
Automatic
- If you trust DHCP to work, you can just try this.
udhcpc -i wlan0
If all goes well, everything will be properly configured and you'll be on the net. Otherwise you should try to do it manually (see below).
Manual
Here are the commands you need to enter to configure the network manually.
- This is optional, but I put it anyway, just in case it causes some kind of trouble.
ifconfig usb0 down
- This disables power management, which can help a dodgy WLAN connection.
iwconfig wlan0 power off
- This limits the rate to 11Mbit, which also can help an unstable WLAN connection.
iwconfig wlan0 rate 11M auto
- Set the IP, broadcast and netmask all at once.
ifconfig wlan0 192.168.1.150/24
- If your network is weird, here's an alternate, more specific line.
ifconfig wlan0 192.168.1.150 broadcast 192.168.1.255 netmask 255.255.255.0
- Add the route to the gateway.
route add default gw 192.168.1.1
Replace 192.168.1.1 with your gateway IP (You can get this from one of your other computers on the network. Linux: ifconfig Windows: ipconfig /all) and 192.168.1.150 with the IP you'd like your Pandora to be. There are a few caveats here, though. Simply put, the subnet needs to be the same as your gateway's subnet. So if it's 192.168.X.Y, it needs to start with 192.168.X or if it's 10.0.0.1, it needs to start with 10. Also for 10.0.0.1, the /24 needs to be /8. There's a bunch of other stuff to do with that, and many odd variations on it, but I'm sure there's a better reference for it elsewhere.
- One last thing you'll need to do is set up DNS name servers. You can get this information from another computer on the network with a working Internet connection.
Linux
cat /etc/resolv.conf
- Copy that file verbatim in to the /etc/resolv.conf on the Pandora.
Windows
ipconfig /all
- There should be a line for Primary DNS Server and possibly Secondary DNS Server. They should be entered in to /etc/resolv.conf like this.
nameserver Primary.DNS.Server.IP
nameserver Secondary.DNS.Server.IP
If there is no secondary DNS server, don't worry, just enter only the first line, then.