A new configuration...
I didn't like the set up I had with my raspberry pi on the public wifi network and hard-wired to a private mesh network to the internal private network. Something was slowing it down and not sure what, but I suspect the private mesh network.
Anyway, I managed to get the PI connected to two wireless networks at the same time. Here's what I did:
1) Reformat the SD card with Wheezy
2) Plug in both wifi dongles into the externally powered USB hub and plug the hub into the pi. (Note: Make sure the two wifi networks are on different channels. Not sure what will happen with the channels overlap)
3) Make /etc/network/interfaces look like this:
proto=RSN
I didn't like the set up I had with my raspberry pi on the public wifi network and hard-wired to a private mesh network to the internal private network. Something was slowing it down and not sure what, but I suspect the private mesh network.
Anyway, I managed to get the PI connected to two wireless networks at the same time. Here's what I did:
1) Reformat the SD card with Wheezy
2) Plug in both wifi dongles into the externally powered USB hub and plug the hub into the pi. (Note: Make sure the two wifi networks are on different channels. Not sure what will happen with the channels overlap)
3) Make /etc/network/interfaces look like this:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_clevelandst.conf
iface private inet static
address 192.168.2.1
network 255.255.255.0
allow-hotplug wlan1
iface wlan1 inet manual
wpa-roam /etc/wpa_supplicant/wpa_philly.conf
iface public inet dhcp
4) Make /etc/wpa_supplicant/wpa_supplicant.conf:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
source wpa_public.conf
source wpa_private.conf
5) wpa_public.conf:
network={
ssid="..."
id_str="public"
key_mgmt=NONE
auth_alg=SHARED
wep_key0=..
}
6) wpa_private:
network={
ssid="..."
psk="..."
id_str="private"
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}
7) sudo apt-get purge ifplugd (Note: For some reason, ifplugd would disconnect one of the networks with the other was connected. Didn't look at config files to see why as this was recommended on raspberry pi forum.)
8) Reboot
9) Now running iwconfig should show both wlan[01] connected and ifconfig should show IP addresses
10) Set up DHCP on private network. Install dhcp server:
sudo apt-get install isc-dhcp-server
11) Edit /etc/dhcp/dhcpd.conf:
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 21600;
max-lease-time 43200;
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
}
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.50 192.168.2.75;
option routers 192.168.2.1;
option domain-name-servers 8.8.8.8, 8.8.4.4;
}
12) Edit /etc/default/isc-dhcp-server:
DHCPD_CONF=/etc/dhcp/dhcpd.conf
DHCPD_PID=/var/run/dhcpd.pid
INTERFACES="wlan0"
13) Start DHCP server (it will automatically start at boot, but this step will check for errors in config file):
sudo /etc/init.d/isc-dhcp-server start
14) Try and connect to private network and see that DHCP IP is issued.
15) Update timezone data:
sudo mv /etc/localtime /etc/localtime.old
sudo ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime
16) Set up ip forwarding (aka establish pi as router). Edit /etc/sysctl.conf and uncomment:
net.ipv4.ip_forward=1
17) Enable the IP forwarding change without rebooting:
sudo echo 1 > /proc/sys/net/ipv4/ip_forward
18) Set up IP Masquerading:
sudo iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE
sudo iptables -A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o wlan1 -j ACCEPT
19) Try browsing from the private network. All should work at this point.
20) Save iptables
cd
sudo iptables-save > iptables
sudo mv iptables /etc/
21) Make the file /etc/network/if-up.d/iptables:
#!/bin/sh
iptables-restore < /etc/iptables
22) Make the file /etc/network/if-up.d/iptables executable
sudo chmod +x /etc/network/if-up.d/iptables
23) Try rebooting and see that you can browse from the private network.