1

I just got a RasPi B+ and I'm looking to replace the Windows PC that's doing the routing job.

What I'm trying to do with the Pi is making it share the connection (wlan0) with another wifi router (via eth0) to distribute the connection. So that makes the pi a wireless-to-wired router/bridge I think.

So, here's my setup:

wifi that occasionally disconnects -->RasPi(THE ONE HAVING ISSUES) --> Wifi router --> Devices inside house

So far, iptables did its job and sort of shared the internet connection (forwarded packets). But, I'm having an issue right now. The internet connection sharing completely disappears when either eth0 or wlan0 gets disconnected. What should I do?

I found a script that auto-reconnects the wifi connection, but sharing is lost. The pi can connect to the internet but the connection is lost for the wifi router and all its clients. I have to reboot the pi to get sharing back. I have no idea what's causing this. Here's the link: http://www.raspberrypi.org/forums/viewtopic.php?t=16054

cat /etc/network/interfaces

auto lo
iface lo inet loopback

# wireless interface
allow-hotplug wlan0
iface wlan0 inet dhcp
 wpa-ap-scan 1
 wpa-scan-ssid 1
wpa-conf /etc/wpa.conf


##CONFIG FOR INTERNET SHARING/ROUTER
allow-hotplug eth0
iface eth0 inet static
  network 192.168.0.0
  netmask 255.255.255.0
  address 192.168.0.1
  broadcast 192.168.0.255
  gateway 192.168.0.1

internet sharing script, runs at startup via /etc/rc.local

sysctl -w net.ipv4.ip_forward=1
sysctl -p
iptables -X
iptables -F
iptables -t nat -X
iptables -t nat -F
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -I FORWARD  -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -I POSTROUTING -o wlan0 -j MASQUERADE

script that reconnects the wifi, runs in background. Also re-runs the internet sharing script.

while true ; do
   if sudo ifconfig wlan0 | grep -q "inet addr:" ; then
      echo "Everytnin' be good. Checking wifi again in 20 seconds."
      sleep 20
   else
      echo "Wifi connection down! Attempting reconnection."
      sudo ifup --force wlan0
      sudo /usr/local/bin/ishare
      sleep 10
   fi
done
  • I think debian and raspbian are very much identical. Raspbian is just an ARM version of debian. – Gene Dec 22 '14 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.