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 →
- Add a table in
/etc/iproute2/rt_tables:100 ispb - Add a default route in it:
ip route add default via 203.0.113.1 dev eth1 table ispb - Add the rule:
ip rule add from 10.0.0.50/32 table ispb priority 1000 - Verify with
ip rule showandip 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.
More on Addressing, CIDR & Routing
You own 10.0.0.0/16 for a new VPC and need separate /24 subnets for dev, QA and prod across two AZs. How do you carve it up?BeginnerA host is configured as 192.168.1.130/25. What network does it belong to and what is the broadcast address?BeginnerHow many usable IPs does an AWS subnet of /28 have?BeginnerA route table has 10.0.0.0/16 -> local and 10.0.1.0/24 -> vpn-gw. Where does a packet to 10.0.1.5 go?BeginnerA newly built server can ping everything in its subnet but nothing outside. What is the first thing you check?BeginnerYou are picking a private range for a new company network. Which RFC 1918 range do you choose and why?Beginner