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.

My computer:

# IP addresses

# IP routes
default via dev wlan0  proto static  metric 600 dev wlan0  scope link  metric 1000 dev wlan0  proto kernel  scope link  src  metric 600 dev eth0  scope link 

My Pi:

# IP address

# IP routes
default via dev eth0
default via dev eth0  proto static  metric 1024 dev wlan0  scope link  metric 1000 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 iptables?


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 -j MASQ

Why is there a DENY ?
For my subnetwork, it's

/sbin/ipchains -A forward -s -j MASQ

Right ?

I found a newer tutorial as suggested by Henrik.
In the /etc/rc.local file, I added:

iptables -t nat -A POSTROUTING -s -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 ( 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 wlan0.

  • If that tutorial talks about 2.2 kernels you really should find a newer. Apr 2, 2016 at 7:32
  • I found a newer, but it's not completely working! :s
    – Phantom
    Apr 3, 2016 at 10:10
  • There's not much to go on now. If only ICMP gets through you must have some firewall rules on the computer doing the masquerading. is not the ip for google.com, but for their public DNS service. If you don't have firewall rules that only allow ICMP, my guess would be that you forgot to enable ip forwarding on the computer, if that's not the case we'll need a lot of details about yor setup to figure out what is wrong. Apr 3, 2016 at 21:50
  • You're write, it was because of my firewall. No it's working! \o/ Thanks ;)
    – Phantom
    Apr 4, 2016 at 15:45

1 Answer 1


You need to turn on forwarding (might be on by default), and setup masquerading (just a fancy word for a special kind of NAT, but it will probably help you to know what to search for).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .