Raspberry Pi Hidden Wifi Netwrok

MULTIPLE WIFI NETWORK RPI

Do not need to edit iterface file just edit wpa_supplicant.conf like this

network={       ssid="open"       key_mgmt=NONE       id_str="open"       priority=3 }  network={         ssid="secure"         key_mgmt=WPA-EAP         proto=WPA2         group=CCMP         pairwise=CCMP         eap=TLS         ca_cert="/etc/certs/cacert.pem"         client_cert="/etc/certs/client.pem"         private_key="/etc/certs/client.key"         private_key_passwd="somepwd"         identity="me"         priority=5 }  network={         ssid="AndroidAP"         key_mgmt=WPA-PSK         proto=WPA2         pairwise=CCMP         group=CCMP         psk="SomeP4ssw0rd"         priority=4 }   network={         ssid="Spooky"         key_mgmt=NONE         group=WEP104         psk="A4ABC2FC27412D4D23CAEBCA23"         priority=2 }  network={         ssid="another"         key_mgmt=WPA-PSK         proto=WPA2         pairwise=CCMP         group=CCMP         psk="A very long and secret passphrase here"         priority=1 }

SETTING UP RASPBERRY PI WITH WIFI AND A STATIC IP ON A HIDDEN SSID

There are a lot of posts out there on this topic but unfortunately they all contain incorrect information and don’t work. After several hours and much head banging I finally got it. So I’m going to settle this once and for all. Here is my setup. I have a Raspberry Pi model B running Raspbian, a BUFFALO AirStation HighPower N150 Wireless USB Adapter – WLI-UC-GNHP, and a hidden SSID. lsusb reports this as

Bus 001 Device 004: ID 0411:0158 BUFFALO INC. (formerly MelCo., Inc.) WLI-UC-GNHP Wireless LAN Adapter

Before I continue, yes I know the usual lecture about using a hidden SSID so you can save your breath. I’m using one anyway, deal with it.

First, set up the wireless with DHCP to make sure it works with your set up. Then you can change it to static.

Now, on the Pi, open /etc/network/interfaces 

You should see something like 

auto lo

iface lo inet loopback

iface eth0 inet dhcp

iface default inet dhcp

We’re going to make it look like this

auto lo

iface lo inet loopback

iface eth0 inet dhcp

auto wlan0

allow-hotplug wlan0

iface wlan0 inet dhcp

wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

I’ve added or modified the parts in bold. I’ve seen some sources say to add a pre-up command here to run wpa_supplicant. This is incorrect. wpa_supplicant will get run automatically, we don’t need to do it. Besides, the command that I’ve seen doesn’t always work with every adaptor. Let the system handle it, it will figure out the correct way to run wpa_supplicant. Adding your own command will also just cause a bunch of ugly errors at bootup.

Now open /etc/wpa_supplicant/wpa_supplicant.conf

You should see a couple lines already there

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

Add the parts in bold to make it look like this

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

# ap_scan can be 0, 1, or 2. Some sources say to use 2 but it did not work for me. 1 did.

ap_scan=1

eapol_version=1

network={

        ssid="YOURSSID"

       # This is needed for hidden SSIDs

        scan_ssid=1

        mode=0

        psk=reallylonghexnumber

       # RSN for WPA2 or WPA for WPA1

        proto=RSN

       # WPA-PSK or WPA-EAP

        key_mgmt=WPA-PSK

       # CCMP for AES or TKIP for TKIP.

        pairwise=CCMP

       # OPEN for WPA1/2 or SHARED or LEAP

        auth_alg=OPEN

}

Make sure to tab indent the network section

Use a hex version of your passphrase as it will eliminate any messups caused by special characters. To get this use the wpa_passphrase command

wpa_passphrase <SSID> [passphrase]

If you have special characters in your passphrase you can enclose the passphrase with quotes. It will show you what the passphrase was that it used so you can double check it used the correct passphrase.

Note: If you use the actual passphrase it must be inside quotes. The hex number should not be inside quotes

These settings will depend on what you have your network configured with. Adjust them accordinly.

Now cross your fingers and reboot to make sure everything comes up properly

sudo reboot

If everything came up properly and you can connect to your Raspberry Pi over SSH or you can ping google.com congratulations. Continue reading if you want a static IP

Static IP Address

Open /etc/network/interfaces again and we’re going to make some changes

Change 

iface wlan0 inet dhcp

to

iface wlan0 inet static

Now add the following lines. These values will be dependent on your network configuration again. Adjust them accordinly

address 192.168.1.11

netmask 255.255.255.0

broadcast 192.168.1.255

gateway 192.168.1.1

When your finished it should look like this

auto lo  iface lo inet loopback iface eth0 inet dhcp  auto wlan0 allow-hotplug wlan0 iface wlan0 inet static address 192.168.1.11 netmask 255.255.255.0 broadcast 192.168.1.255 gateway 192.168.1.1 wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp

Cross your fingers and reboot again to make sure it all comes up and is working correctly. If you’re able to ping the IP you just configured congratulations.

Normal Setup Wifi

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

network={

ssid="YOURSSID"

psk="YOURPASSWORD"

# Protocol type can be: RSN (for WP2) and WPA (for WPA1)

proto=WPA

# Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)

key_mgmt=WPA-PSK

# Pairwise can be CCMP or TKIP (for WPA2 or WPA1)

pairwise=TKIP

#Authorization option should be OPEN for both WPA1/WPA2 (in less commonly used are SHARED and LEAP)

auth_alg=OPEN

}