Linux: policy based routing - iproute2

Task: A linux box has two aliaces configured on the interface:
em2: ip 10.10.0.10;
em2:0 - ip 10.10.11.1 and em2:1 - ip 10.10.22.2;

There are two routers that traffic can be forwarded to: 10.10.0.100 and 10.10.0.200. All traffic from 10.10.11.1 should be routed to 10.10.0.100 and traffic from 10.10.22.2 should be forwarded to 10.10.0.200.

IP routing

- rules - routing policy database
# ip rule list
0:  from all lookup local
32766:  from all lookup main
32767:  from all lookup default

 

Read more