0

So I have my raspberry pi connected to the internet via my iPhone (tethering via USB), and it all works fine, the connection is setup on eth1. The problem I have is I cannot manage to forward my connection from eth1 (the USB port) to eth0 (the LAN RJ45 port).

I tried using iptables but I am wondering if I did not use the wrong commands ? I also have port forwarded the ipv4. Anyways, the internal IP address of my raspberry pi is 192.168.20.2 and the internal ip address of my iPhone is 192.168.1.6. The tethering is done from the iPhone's wifi (not 3G) but will later be on 3G, to usb.

How would I be able to share the connection from my iPhone to the device, via the raspberry pi acting as the medium as I cannot directly connect a RJ45 cable to the iPhone ?

Thank you !

0

For this to work, you'll need to set up the raspi as a router, as it needs to route traffic from network 192.168.20.xyz to network 192.168.1.abc and vice versa. To do this, change /etc/sysctl.conf so that

net.ipv4.ip_forward=1

is not commented out. You can activate routing as well by doing

sysctl -w net.ipv4.ip_forward=1

But that won't stick after a reboot.

After that, make sure that your raspi's default gateway is the iPhone. Set all the devices on your LAN to use the raspi as the default gateway. This should enable you to share your iPhone's connection to the LAN.

  • The default gateway is indeed my iphone (IP 192.168.20.1) . Now how would I make my device connected via the raspberry pi's lan port, use my iphone's connection ? – Master_yugi Aug 6 '14 at 1:23
  • As I said: set your LAN devices to use the raspi as default gateway – Simon Aug 6 '14 at 9:53
  • I just figured that this approach won't work on its own, as you still need forwarding rules. You'll probably need to use this in conjunction with IPtables – Simon Aug 6 '14 at 10:08
  • Yes, and that's my problem, I have been using iptables command and none of them seem to have worked, as to why I think I use the wrong ones ? – Master_yugi Aug 6 '14 at 10:51

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.