Source policy routing - multihoming: Difference between revisions
Jump to navigation
Jump to search
(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...") |
No edit summary |
||
Line 9: | Line 9: | ||
eth2: 10.10.0.131/24 |
eth2: 10.10.0.131/24 |
||
eth3: 10.20.0. |
eth3: 10.20.0.215/24 |
||
eth2 is primary and reponds to ping - eth3 does not. |
eth2 is primary and reponds to ping - eth3 does not. |
||
Line 18: | Line 18: | ||
<pre> |
<pre> |
||
echo |
echo 1 webserver_vlan >> /etc/iproute2/rt_tables |
||
</pre> |
</pre> |
||
=== Add a default route to this new table going out eth3 === |
=== Add a default route to this new table going out eth3 === |
||
* point to gw on that network |
|||
<pre> |
<pre> |
||
ip route add default via 10.20.0.1 |
ip route add default via 10.20.0.1 dev eth3 table webserver_vlan |
||
</pre> |
</pre> |
||
=== Add a policy rule to use this new table for packets with source address of eth3's IP === |
=== Add a policy rule to use this new table for packets with source address of eth3's IP === |
||
* Use ip of eth3 here. |
|||
<pre> |
<pre> |
||
ip rule add from 10.20.0. |
ip rule add from 10.20.0.215 table webserver_vlan |
||
</pre> |
</pre> |
||
Latest revision as of 07:56, 5 July 2019
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