LINUX - Wireless Cheatsheet

WIRELESS CHEATSHEAT FOR DEBIAN
##############################

--QUICK INSTALL---
apt-get install wireless-tools
aptitude install wireless-tools
apt-get install wpasupplicant

--OR--
Debian 7.0 "Wheezy"
Add a "non-free" component to /etc/apt/sources.list, for example:
# Debian 7.0 "Wheezy"
deb http://http.debian.net/debian/ wheezy main contrib non-free
Update the list of available packages and install the firmware-iwlwifi package:
# apt-get update && apt-get install firmware-iwlwifi
As the iwlwifi module is automatically loaded for supported devices, reinsert this module to access installed firmware:
# modprobe -r iwlwifi ; modprobe iwlwifi
("lsmod" to see if its already joined, "rmmod iwlwifi" or you need to remove it, or BEST REMOTE: "modprobe -r iwlwifi")
Configure your wireless interface as appropriate.
DONT FORGET: apt-get install wpasupplicant

===COMMANDS===
GET NAME OF WLAN0: iwconfig
ALSO: ifconfig
THEN GET ALL ESSIDS: iwlist wlan0 scan

--OTHER--
AVAIL FREQ 4 DEV: iwlist [int] channel 
AVAIL BITRATE 4 DEV: iwlist [int] rate
SUPPORTED ENCR KEY SIZES & ALL KEYS AVAIL: iwlist [int] key
LIST POWER MAN ATTRIBS & MODES: iwlist [int] power 
LIST AVAIL TRANSMIT POWERS: iwlist [int] txpower 
RETY LIMITS & RETRY LIFETIME LIST ON DEV: iwlist [int] retry 
LIST APS IN RANGE & QUALITY (DEPRECATED B/CUZ SCAN BETTER): iwlist [int] ap 
LIST PEERS ASSOCIATED/REGISTERED TO CARD: iwlist [int] peers 
LIST SUPPORTED EVENTS: iwlist [int] event 

---OPEN / WEP (DHCP)---
(128 BIT WEP USE 26 HEX CHARACTERS, 64 BIT WEP USES 10)
iwconfig [int] mode managed key [WEP key] 
iwconfig [int] essid "[ESSID]" 
dhclient [int] 
ping www.google.com

---OPEN / WEP (MANUAL)---
iwconfig [int] mode managed key [WEP key] 
iwconfig [int] essid "[ESSID]"
ifconfig [int] [IP address] netmask [subnetmask]
route add default gw [IP of default gateway]
echo nameserver [IP address of DNS server]  >>  /etc/resolve.conf 
ping www.google.com

---WPA---
SUMMARY:
1st step MAKE CONFIG wpa_passphrase [ssidname] [ssidpassword] > [saved conf file]
2nd step CONNECT:  wpa_supplicant -B -i [int] -c [saved conf file]
3rd step settings: dhcpcd -A [int]

---WPA IN DEPTH---
1st step MAKE CONFIG: wpa_passphrase ssidname ssidpassword > file
TYPICAL FILE FOR CONFIG:/etc/wpa_supplicant/wpa_supplicant.conf
ANOTHER TYPICAL LOCATION: /etc/wpa_supplicant.conf
SO TYPICAL: wpa_passphrase ssidname ssidpassword > /etc/wpa_supplicatnt/wpa_supplicant.conf

TO CONNECT:
wpa_supplicant -B -i [int] -c /etc/wpa_supplicant/wpa_supplicant.conf

---BOTH IN ONE COMMAND:---
wpa_supplicant -B -i [int] -c <(wpa_passphrase [essid] [passphrase])
EXAMPLE:
wpa_supplicant -B -i wlan0 -c <(wpa_passphrase coal01ssid dakota01)

---AFTER THAT SET IPS/ROUTES AND (DNS IF NOT SET)---
DHCP: "dhcpcd -A wlan0" OR WITHOUT -A "dhcpcd wlan0"
MANUAL: 
ifconfig [int] [IP address] netmask [subnetmask]
route add default gw [IP of default gateway]
echo nameserver [IP address of DNS server]  >>  /etc/resolve.conf 
ping www.google.com

--SIDENOTE: FOR wpa_supplicant SOMETIMES NEED TO USE OTHER DRIVER--
LIST ALL DRIVERS: wpa_supplicant -h
RUN WITH OTHER DRIVER (wext for example) (notice here all of the vars, like eth0, are right next to arg., like -ieth0 instead of -i eth0):
wpa_supplicant -Bw -Dwext -ieth0 -c /etc/wpa_supplicant.conf


--FOR DEBUGGING: CAN RUN wpa_supplicant WITHOUT B--
wpa_supplicant -i [int] -c [file]
CONTROL-C to CANCEL and then do again with -B
CONTROL-Z will put in background as if you ran it with -B (might need to resume job using bash job command)

--TO RESUME JOB IN BACKGROUND: if you ran wpa_supplicant without -B and did CONTROL-Z--
LIST JOBS: jobs
RESUME JOB (WHERE 1 IS THE JOB NUMBER): %1 & 

/etc/network/interfaces SUB ARTICLE 
###################################

Debian packages
===============

# apt-get update
# apt-get install udev wireless-tools wpasupplicant
Debian configuration: /etc/network/interfaces

===WPA2===

### DHCP ###
auto wlan0
iface wlan0 inet dhcp
        wpa-ssid YOUR_SSID_GOES_HERE
        wpa-psk YOUR_SECRET_GOES_HERE
        wpa-key-mgmt WPA-PSK
        wpa-pairwise TKIP CCMP
        wpa-group TKIP CCMP
        wpa-proto WPA RSN
        wpa-ap-scan 1
        wpa-scan-ssid 1

### Static IP ###
auto wlan0
iface wlan0 inet static
        wpa-ssid YOUR_SSID_GOES_HERE
        wpa-psk YOUR_SECRET_GOES_HERE
        wpa-key-mgmt WPA-PSK
        wpa-pairwise TKIP CCMP
        wpa-group TKIP CCMP
        wpa-proto WPA RSN
        wpa-ap-scan 1
        wpa-scan-ssid 1
        address YOUR_IP_GOES_HERE
        netmask YOUR_NETMASK_GOES_HERE
        gateway YOUR_GATEWAY_GOES_HERE

Note that you can also use a pre-computed 256-bit PSK as a secret instead of an ASCII passphrase.

To get a 256-bit PSK from an ASCII passphrase use the following command:
# wpa_passphrase your_ssid your_ascii_passphrase

===WEP (ASCII string key)===

### DHCP ###
auto wlan0
iface wlan0 inet dhcp
        wireless-essid YOUR_SSID_GOES_HERE
        wireless-key s:YOUR_ASCII_SECRET_GOES_HERE
### Static IP ###
auto wlan0
iface wlan0 inet static
        wireless-essid YOUR_SSID_GOES_HERE
        wireless-key s:YOUR_ASCII_SECRET_GOES_HERE
        address YOUR_IP_GOES_HERE
        netmask YOUR_NETMASK_GOES_HERE
        gateway YOUR_GATEWAY_GOES_HERE
===WEP (binary key)===

### DHCP ###
auto wlan0
iface wlan0 inet dhcp
        wireless-essid YOUR_SSID_GOES_HERE
        wireless-key 0123-4567-89

### Static IP ###
auto wlan0
iface wlan0 inet static
        wireless-essid YOUR_SSID_GOES_HERE
        wireless-key 0123-4567-89
        address YOUR_IP_GOES_HERE
        netmask YOUR_NETMASK_GOES_HERE
        gateway YOUR_GATEWAY_GOES_HERE
===Open===

### DHCP
auto wlan0
iface wlan0 inet dhcp
        wireless-essid YOUR_SSID_GOES_HERE
### Static IP
auto wlan0
iface wlan0 inet static
        wireless-essid YOUR_SSID_GOES_HERE
        address YOUR_IP_GOES_HERE
        netmask YOUR_NETMASK_GOES_HERE
        gateway YOUR_GATEWAY_GOES_HERE
Debian operation
================

Issue the following command to manually enable the WLAN connection:
# ifup wlan0
Issue the following command to manually disable the WLAN connection:
# ifdown wlan0
Comments