User Tools

Site Tools


setupwlan

How-to setup Wireless-LAN

To setup Wireless-LAN on the RaspberryPi is not that easy, when you want to use a static IP per different SSID/network. With ifconfig you are able to see your current IP, if it's working.

But let's see what should be modified to get a basic WLAN-setup working with static IPs:

First modify the “/etc/network/interfaces”:

/etc/network/interfaces
auto lo
 
iface lo inet loopback
#iface eth0 inet dhcp
 
iface eth0 inet static 
  address 192.168.0.204
  netmask 255.255.255.0
  network 192.168.0.0
  broadcast 192.168.0.255
  gateway 192.168.0.254
 
allow-hotplug wlan0
iface wlan0 inet manual
  wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
 
iface myuniqueid inet static
   address 192.168.0.205
   netmask 255.255.255.0
   network 192.168.0.0
   broadcast 192.168.0.255
   gateway 192.168.0.254
 
iface default inet dhcp

Then modify the “/etc/wpa_supplicant/wpa_supplicant.conf”:

/etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
#ap_scan=1
 
network={
   ssid="My-Wireless-SSID"
   scan_ssid=1
   psk="WIFI-password"
   proto=RSN
   key_mgmt=WPA-PSK
   pairwise=CCMP
   id_str="myuniqueid"
   #priority=5
}

Once you have edited, saved and closed the files you need to reboot or stop wlan0:

sudo wpa_action wlan0 stop

Then load it back up with the new wpa config:

sudo ifup wlan0

After wlan0 has come back up, check to see if you have connectivity:

sudo wpa_cli status

This setup includes a static IP for “eth0” and for the working wifi-device known as “wlan0”. The identifier “myuniqueid” is free to choose identifier. It just has to be equal in both files!

Setup static WLAN with more than one network

Setup the “/etc/network/interfaces”:

/etc/network/interfaces
auto lo
 
iface lo inet loopback
#iface eth0 inet dhcp
 
iface eth0 inet static 
  address 192.168.0.204
  netmask 255.255.255.0
  network 192.168.0.0
  broadcast 192.168.0.255
  gateway 192.168.0.254
 
allow-hotplug wlan0
iface wlan0 inet manual
  wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
 
iface myuniqueid1 inet static
   address 192.168.0.205
   netmask 255.255.255.0
   network 192.168.0.0
   broadcast 192.168.0.255
   gateway 192.168.0.254
 
iface myuniqueid2 inet static
   address 192.168.1.123
   netmask 255.255.255.0
   network 192.168.1.0
   broadcast 192.168.1.255
   gateway 192.168.1.1
 
iface default inet dhcp

Then modify the “/etc/wpa_supplicant/wpa_supplicant.conf”:

/etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
#ap_scan=1
 
network={
   ssid="My-Wireless-SSID"
   scan_ssid=1
   psk="WIFI-password"
   proto=RSN
   key_mgmt=WPA-PSK
   pairwise=CCMP
   id_str="myuniqueid1"
   priority=5
}
 
network={
   ssid="Another-SSID"
   scan_ssid=1
   psk="Some-password"
   proto=RSN
   key_mgmt=WPA-PSK
   pairwise=CCMP
   id_str="myuniqueid2"
   priority=15
}

By setting up a priority, the raspi chooses first the wifi with the higher prio if both are available!

setupwlan.txt · Last modified: 18.10.2013 19:05 by andreas