Networking

Connecting to a WIFI from the command line

Assumptions

Router is on 192.168.1.1 Own ip address will be 192.168.1.200

Required packages

wpasupplicant
net-tools

Commands

iwlist wlan0 scan  # to find available networks
ifup wlan0         # bring up wlan interface
ifdown wlan0       # bring down wlan interface
service networking restart   # restart networking
ifconfig           

Config files

/etc/resolv.conf

nameserver 192.168.1.1

/etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# Wifi adapter
auto wlan0
iface wlan0 inet static
   address 192.168.1.200
   broadcast 192.168.1.255
   dns-nameservers 192.168.1.1
   gateway 192.168.1.1
   netmask 255.255.255.0
   network 192.168.1.0
   wpa-driver wext
   wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
network={
   ssid=<the ssid>
   psk=<the key>
}

Where psk is the generated pre-shared key for your ssid / passphrase combination. You can generate it with

wpa_passphrase <the ssid> <the passphrase>