Interview Prep/Networking/Addressing, CIDR & Routing

Traffic from one source IP should leave through ISP B while everything else uses ISP A. How do you do it on Linux?

IntermediateScenarioAddressing, CIDR & Routing
Answer

Situation read → This is policy-based routing: a rule chooses a routing table based on the packet source.

What I'd do →

  1. Add a table in /etc/iproute2/rt_tables: 100 ispb
  2. Add a default route in it: ip route add default via 203.0.113.1 dev eth1 table ispb
  3. Add the rule: ip rule add from 10.0.0.50/32 table ispb priority 1000
  4. Verify with ip rule show and ip route get 8.8.8.8 from 10.0.0.50 iif eth0

Why → The kernel evaluates rules in priority order and uses the table of the first match, so the main table is only the fallback.

Interview tip → Mention making it persistent via netplan routing-policy or systemd-networkd.

All Networking questions Roadmap: Networking for DevOps

More on Addressing, CIDR & Routing