Interview Prep/Networking/IP Addressing, CIDR, Subnetting & Routing

What is policy-based routing and when would you use it?

AdvancedConceptIP Addressing, CIDR, Subnetting & Routing
Answer

Normal routing uses only the destination address. Policy-based routing chooses a table by source IP, mark, interface or other fields using ip rule. Typical cases: multi-homed servers with two NICs where replies must leave via the interface the request arrived on, or steering certain traffic through a VPN.

ip rule add from 10.0.2.10 table 100
ip route add default via 10.0.2.1 dev eth1 table 100

Asymmetric routing on multi-NIC instances is the usual reason you need it.

All Networking questions Roadmap: Networking for DevOps

More on IP Addressing, CIDR, Subnetting & Routing