Source policy routing - multihoming

From Skytech
Revision as of 07:56, 5 July 2019 by Martin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Source policy routing

If a machine has several interfaces, but only 1 default gateway - it is multihomed and unless the gw supports handling packages with 'wrong' source mask, then linux must be told to route packets via the default gw.

Solution

Problem: Host has 2 interfaces.

eth2: 10.10.0.131/24 eth3: 10.20.0.215/24

eth2 is primary and reponds to ping - eth3 does not.

Create new routing table (only needs to be done once)

Naming doesn't matter, it just needs to be unique. A telling name makes sense though.

echo 1 webserver_vlan >> /etc/iproute2/rt_tables

Add a default route to this new table going out eth3

  • point to gw on that network
ip route add default via 10.20.0.1 dev eth3 table webserver_vlan

Add a policy rule to use this new table for packets with source address of eth3's IP

  • Use ip of eth3 here.
ip rule add from 10.20.0.215 table webserver_vlan

Lookup new rule

ip rule show

Source