0

I have a quick question regarding the behaviour of priority when using policy based routing. I'm running Ubuntu 18.04 (kernel is 4.15.0-1021-aws).

I'm using this machine as a gateway to forward packets from one interface to another. Let's say eth0 -> eth1.

For packets generated by the machine itself, I don't want them to be routed through eth1 ever. However, packets originating from different machines (in the same subnet as eth0, 192.168.0.0/24) need to be routed through eth1.

The ip address of eth0 is 192.168.0.1. The routing table for forwarding packets is called forwarded. So I have added the following rules:

0:  from all lookup local 
1:  from 192.168.0.1/32 lookup default 
10: from 192.168.0.1/24 lookup forwarded 
32766:  from all lookup main 
32767:  from all lookup default 

However, when I try and ping from this machine, it uses the forwarded routing table. Is there a way of doing this or have I made some error here?

1 Answer 1

0

Packets created on the local machine first of all recieve 0.0.0.0/32 as source ip, which is called the unspecified address and this address is at some point replaced by the kernel with the ip of the interface through which the packet leaves the machine.

To properly route the local sourcing packets it is often helpful to use a from 0.0.0.0/32 rule to delegate those in the right direction. This is escpecially important for packets from services which are not bound to a specific interface interface ip.

You must log in to answer this question.

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