2

I have a raspberry pi B+ set up in a server configuration and it connects to internet successfully over Wifi with a USB dongle.

My other pi (an A+) has always been located downstairs in the garage, getting an internet connection from an ethernet cable to my modem.
Though having to run downstairs to modify the pi or disconnect it is kinda frustrating when doing it multiple times a day.

I wondered if there was a way that my B+ could share its wifi connection to my A+ over ethernet. The A+ would connect with an ethernet cable to the B+ ethernet port then.

I also have a 10/100 switch laying around if needed.

migrated from raspberrypi.stackexchange.com May 15 '15 at 10:22

This question came from our site for users and developers of hardware and software for Raspberry Pi.

  • you should be able to share the internet on PiB+ and create a network bridge to the PiA+.. depending on the distro you have installed there are commands for that.. – rwenz3l May 15 '15 at 10:37
  • @YoshiBotX I don't see why this should be distro specific. – goldilocks May 15 '15 at 13:00
  • Presumably you have added a USB-Ethernet adapter to the A+? It's not clear how moving the near end of the Ethernet cable from the modem to the B+ is going to help you with remote configuration/modification or whatever of the downstairs A+. What could be interesting would be a long-haul serial transceiver (possibly re-purposing UTP cable) or even a serial-radio bridge plugged into the downstairs A+'s console UART. – Chris Stratton May 15 '15 at 15:37
4

Depending on what you are running on the raspberry pi with wifi and ethernet you could be able to install iptables:

Then configure ip forwarding by:

echo 1 > /proc/sys/net/ipv4/ip_forward
sysctl -w net.ipv4.ip_forward=1 # to make ip_forwarding persistent across reboots 

and an iptables rule to masquerade outgoing traffic

iptables -t nat -A POSTROUTING -s <your-ethernet-ip-subnet> -j MASQUERADE
iptables-save # to make the iptables rule persistent across reboots 

Use a dedicated internal subnet for your ethernet connection. If, for instance, your wifi uses 192.168.1.0/24 use for example 192.168.2.0/24 on your ethernet connection.

  • Running Raspbian. I'll try using iptables and check back when I tried. – thibmaek May 15 '15 at 11:16
  • 1
    Seems like it might be a good answer but iptables-save does not make anything "persistent across reboot". It spits out the current rules. You have to save those to a file and then reload them at boot. E.g., iptables-save > /etc/iptables.rules and then on Raspbian, add iptables-restore < /etc/iptables.rules to /etc/rc.local. I hope the other details here are correct, I have not done this before. – goldilocks May 15 '15 at 13:03
  • Sure, the iptables-save part is a assumtion by me, I regularly use custom iptables scripts and therefor don't use iptables-save. Will have a look on the default save details for debian and update my answer accordingly – Lambert May 15 '15 at 13:10
1

You could also use ethernet over power adapters and share a wired connection. I use them and have a set of 500mbs adapters. They work flawlessly. You can get them at Newegg or on Ebay for a very reasonable price.

  • 1
    Powerlines you mean? – thibmaek Jan 14 '17 at 19:08

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.