I connected my Pi to my home computer through an Ethernet link. My computer is connected to the Internet by a wireless connection. And I'd like to route all Internet traffic from my Pi by my computer.
I set a /30 subnetwork on the Ethernet link, and I added routes on both, so they can ping each other.
Here are my configurations.
# IP addresses eth0 192.168.1.1/30 wlan0 192.168.0.13/24 # IP routes default via 192.168.0.254 dev wlan0 proto static metric 600 169.254.0.0/16 dev wlan0 scope link metric 1000 192.168.0.0/24 dev wlan0 proto kernel scope link src 192.168.0.13 metric 600 192.168.1.0/30 dev eth0 scope link
# IP address eth0 192.168.1.2/30 # IP routes default via 192.168.1.1 dev eth0 default via 192.168.1.1 dev eth0 proto static metric 1024 169.254.0.0/16 dev wlan0 scope link metric 1000 192.168.1.0/30 dev eth0 scope link
On my computer, to route all traffic from eth0 to wlan0, do I just have to add some routes? Or do I have to use NAT with
After the Henrik's answer I did some search about masquerading, and I found this tutorial.
In this, he says to check if the masquerading kernel support is up, by looking in the
/proc/net dir, for a 2.2x kernel.
In my 4.2.x kernel, I didn't find the file that he mentions, but I found some
*masquerade*.ko files. Is this mean masquerading support is up in my kernel?
If not, is there a way to set it up without recompile my kernel ?
At the end of the tutorial, he gives some firewall rules to make the masquerading.
The first one is:
/sbin/ipchains -A input -j ACCEPT -i eth1 -s 0/0 67 -d 0/0 68 -p udp
This is just to let the DHCP requests go trough for the "hidden" computer. But me I fixed the Ip manually on my PI, so I don't need it, right ?
Then, there are this two rules:
/sbin/ipchains -P forward DENY /sbin/ipchains -A forward -s 10.1.199.0/24 -j MASQ
Why is there a
For my subnetwork, it's
/sbin/ipchains -A forward -s 192.168.1.0/30 -j MASQ
I found a newer tutorial as suggested by Henrik.
/etc/rc.local file, I added:
iptables -t nat -A POSTROUTING -s 192.168.1.0/30 -o wlan0 -j MASQUERADE
So now the masquerading seems to be working, but not completely.
Indeed, when I try to ping google.com with the IP address (22.214.171.124) it's working, but if I try with the url it's not.
I supposed it was because of somes DNS porblems, so I add some DNS's IPs in the
/etc/resolv.conf file. And it changed nothing.
So I tried to go to DuckDuckgo with the IP address in Firefox, and it's not working.
So it seems, only ICMP traffic is forwarded. I checked with wireshark what is coming from
eht0 and what is living by