I'm using this Adafruit guide for turning my Raspberry Pi 2 B+ into a wifi router. I've got all the software installed and it works! Well, sort of.
I can connect to the router A-OK, and if I run
python -m SimpleHTTPServer
Then I can navigate to 172.16.1.1:8000
and I get the webpage just fine. So I know traffic is working to/from the pi. However, I can't get beyond that. ping 8.8.8.8
doesn't work with:
ping: sendto: Network is unreachable
Request timeout for icmp_seq 0
Trying to ping an actual domain name (e.g. mit.edu
or google.com
) fails with
ping: cannot resolve mit.edu: unknown host
My only thought is that it's iptables not working correctly, but it looks just like the screenshot from the Adafruit guide:
pi@raspberrypi:~ $ sudo iptables -t nat -S
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-A POSTROUTING -o eth0 -j MASQUERADE
pi@raspberrypi:~ $ sudo iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o eth0 -j ACCEPT
And I know that I can get to the Internet from my Pi:
pi@raspberrypi:~ $ curl google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
Other relevant sections:
/etc/network/interfaces:
allow-hotplug wlan0
iface wlan0 inet static
address 172.16.1.1
netmask 255.255.255.0
/etc/dhcp/dhcpd.conf:
# Don't worry about eth0's network
subnet 192.168.42.0 netmask 255.255.255.0 {
}
subnet 172.16.1.0 netmask 255.255.255.0 {
range 172.16.1.100 172.16.1.200;
option broadcast-address 172.16.1.255;
option routers 172.16.1.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}
/etc/default/isc-dhcp-server:
DHCPD_CONF=/etc/dhcp/dhcpd.conf INTERFACES=""
/etc/hostapd/hostapd.conf:
interface=wlan0
ssid=my_network
channel=1
#bridge=br0
# WPA and WPA2 configuration
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=surewhynotputmyrealpasswordhere
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
# Hardware configuration
driver=nl80211
ieee80211n=1
hw_mode=g
device_name=RTL8192CU
manufacturer=Realtek
/etc/default/hostapd:
DAEMON_CONF="/etct/hostapd/hostapd.conf"
netstat -au (on the raspberry pi):
pi@raspberrypi:~ $ netstat -au
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 *:52375 *:*
udp 0 0 *:43975 *:*
udp 0 0 *:mdns *:*
udp 0 0 *:bootps *:*
udp 0 0 *:bootpc *:*
udp 0 0 raspberrypi.local:ntp *:*
udp 0 0 172.16.1.1:ntp *:*
udp 0 0 192.168.42.134:ntp *:*
udp 0 0 localhost:ntp *:*
udp 0 0 *:ntp *:*
udp6 0 0 [::]:mdns [::]:*
udp6 0 0 [::]:42265 [::]:*
udp6 0 0 fe80::6cce:ea5d:5d7:ntp [::]:*
udp6 0 0 fe80::ee35:b0ca:cdc:ntp [::]:*
udp6 0 0 localhost:ntp [::]:*
udp6 0 0 [::]:ntp [::]:*
udp6 0 0 [::]:52608 [::]:*
More updates:
So, the strangeness - it seems that I can connect just fine via my Samsung Galaxy Note Tablet and my alcatel cell phone. I haven't tried chromebooks yet, but it appears that just my Mac is having the trouble connecting.
(tried with chromebooks now, it works just fine)