Routing tables and ip forwarding between two machines

Posted on

Problem :

Hi my current network is like that

eth0 =
p3p1 =
wlp3s0 =
Router =

I would like to give access to the Internet to Raspberry.
I turned on port forwarding on Laptop

[kamil@laura ~]$ cat /proc/sys/net/ipv4/ip_forward 

I checked route table on Raspberry

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         UG    0      0        0 eth0      *        U     0      0        0 eth0

I set up route on my Laptop:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         router         UG    0      0        0 wlp3s0   U     1      0        0 p3p1   U     9      0        0 wlp3s0

But my Raspberry cant ping router ip address, it waits all the time.
What am I missing, please help!

IPTables are turned off on both machines.

Solution :

Try this:

  1. Change the IP address on the p3p1 interface of your laptop to

  2. Enable IP forwarding (not port forwarding) on your laptop. If it’s Linux, use:
    sysctl -w net.ipv4.ip_forward=1

  3. Add a route to your router: next-hop:

You may have to mess with NAT on the router, to NAT for 10.x.x.x addresses. That would depend on the brand of router.

There are a lot of reasons why this won’t work. Here are two:

  1. The router has no idea that it’s supposed to NAT for machines with 10.x addresses. It believes its clients have 192.168.x addresses.

  2. The router has no idea that packets (even locally generated ones) bound for should be sent to the laptop. Yet there is no other IP address it can use as a destination to get packets to the pi. Thus the router cannot reach the pi. At all. By any means. Period.

You need to start out by designing the way this will all work and then implement that. It won’t just happen by itself. Implementing NAT on the laptop would probably be the easiest way.

Leave a Reply

Your email address will not be published. Required fields are marked *