Source policy routing - multihoming

From Skytech
Revision as of 13:07, 12 April 2018 by Martin (talk | contribs) (Created page with "Category:Linux = Source policy routing = If a machine has several interfaces, but only 1 default gateway - it is multihomed and unless the gw supports handling packages w...")
(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.2/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 13 eth3 >> /etc/iproute2/rt_tables

Add a default route to this new table going out eth3

ip route add default via 10.20.0.1 table eth3

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

ip rule add from 10.20.0.2 lookup eth3

Lookup new rule

ip rule show

Source