1

So I have an embedded device, and his only way of (fast) communication with the outside world is to NAT him through my development laptop, which is connected to the internet via WiFi.

The IP address of my interface connected to the device is 192.168.7.1. The devices IP address is 192.168.7.2. The IP of my WiFi interface doesn't matter.

The way I set up my iptables and port forwarding on my laptop is as follows:

iptables -t nat -A POSTROUTING ! -d 192.168.7.2/8 -j MASQUERADE
sysctl net.ipv4.ip_forward=1

On my device, I add the IP address of my laptop's interface (192.168.7.1) as a default gateway, and BAM... I can ping the internet from my tiny device. This is awesome for getting packages, files, I can ssh into any box I want from behind this device, etc.

However, for some reason, nothing related to git with my projects on Github works. When I git clone <github repo>, it hangs and eventually times out with

Failed to connect to github.com port 443: Connection timed out

I have no idea why this is, but I would really like to find a solution. I'm developing software for the device, and it's much easier to push from /it/ than rsync it to my laptop, and push from there (I know not by very much). It's also a networking exercise as I'd like to know what Github is doing differently than basically everything else o_O

I tried setting my "proxy" as my laptop by following the question here: Getting git to work with a proxy server, but it didn't work either.

Also, I can check out my projects on Bitbucket. It seems to work fine there.

Thanks.

Community
  • 1
  • 1
justynnuff
  • 461
  • 1
  • 6
  • 20

1 Answers1

0

Turns out I was setting my iptables wrong somehow.

To get it to work, I have to execute the following on my laptop:

iptables --table nat --append POSTROUTING --out-interface <interface facing the internet> -j MASQUERADE
iptables --append FORWARD --in-interface <interface connected to device> -j ACCEPT
sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

I have no idea why the previous script didn't work (for Github only) and this one does, but this does indeed solve it for me.

This info was found here: https://www.raspberrypi.org/forums/viewtopic.php?t=6997&p=87671.

justynnuff
  • 461
  • 1
  • 6
  • 20