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.
More on IP Addressing, CIDR, Subnetting & Routing
What is an IPv4 address and how is it structured?BeginnerWhat are the private IPv4 ranges (RFC 1918)?BeginnerWhat is CIDR notation?BeginnerHow many usable hosts are in a /24, and why minus two?BeginnerSubnet 10.0.0.0/16 into /24 subnets. How many do you get and what are the first three?IntermediateGiven 172.16.37.200/21, what is the network address, broadcast and range?Intermediate