Two Interfaces on the Same Subnet
Intermediate TroubleshootQuestion
A server has two network interfaces, eth0 and eth1, both configured in the 10.0.0.0/24 subnet. eth0 has IP 10.0.0.5/24 with gateway 10.0.0.1, and eth1 has IP 10.0.0.200/24 with gateway 10.0.0.1. Routing behaves unpredictably — some connections drop and asymmetric routing is observed. Identify the problem.
Given
{
"interface_a": {
"ip": "10.0.0.5/24",
"gateway": "10.0.0.1"
},
"interface_b": {
"ip": "10.0.0.200/24",
"gateway": "10.0.0.1"
}
}
Answer
{
"problem": "Both interfaces are in the same 10.0.0.0/24 subnet, creating routing ambiguity",
"both_in_subnet": "10.0.0.0/24",
"issue_1": "OS cannot determine which interface to use for outbound traffic to the same subnet",
"issue_2": "Inbound replies may arrive on either interface, causing asymmetric TCP flows",
"issue_3": "Default gateway via both interfaces creates duplicate route entries",
"fix": "Move eth1 to a different subnet (e.g. 10.0.1.200/24) or use policy-based routing with separate routing tables"
}
Try to solve it first, then click Reveal Answer
Step-by-Step Explanation
Step 1: Identify the subnet conflict
Both interfaces: - eth0: 10.0.0.5/24 → subnet 10.0.0.0/24 - eth1: 10.0.0.200/24 → subnet 10.0.0.0/24
Both belong to exactly the same subnet. This is the root cause.
Step 2: How the OS routing table looks
Destination Gateway Iface
10.0.0.0/24 0.0.0.0 eth0 ← connected route
10.0.0.0/24 0.0.0.0 eth1 ← DUPLICATE!
0.0.0.0/0 10.0.0.1 eth0 ← default via eth0
0.0.0.0/0 10.0.0.1 eth1 ← DUPLICATE default!
Linux uses ECMP (Equal-Cost Multi-Path) or the last-added route. Which interface is used for any given packet is non-deterministic. This breaks: - Stateful firewalls (track flows per interface) - TCP sessions (SYN sent on eth0, SYN-ACK received on eth1) - NAT (source IP tracking)
Step 3: Why asymmetric routing breaks TCP
Client → Server (10.0.0.5 via eth0):
SYN arrives on eth0
SYN-ACK sent via eth1 (kernel chose different interface)
Client sees SYN-ACK from 10.0.0.200, not 10.0.0.5
Connection drops or hangs
Step 4: Fix options
Option A — Move eth1 to a different subnet:
# Remove current eth1 config
sudo ip addr del 10.0.0.200/24 dev eth1
# Assign new address in different subnet
sudo ip addr add 10.0.1.200/24 dev eth1
# Add specific route for eth1's network
sudo ip route add 10.0.1.0/24 dev eth1
Option B — Policy-based routing (advanced): If both interfaces must stay in the same physical subnet (e.g., different upstream ISPs), use Linux policy routing:
# Create separate routing tables
echo "200 eth0table" >> /etc/iproute2/rt_tables
echo "201 eth1table" >> /etc/iproute2/rt_tables
# Add rules: traffic from each IP uses its own table
ip rule add from 10.0.0.5 table eth0table
ip rule add from 10.0.0.200 table eth1table
# Each table has its own default route
ip route add default via 10.0.0.1 table eth0table
ip route add default via 10.0.0.1 table eth1table
Step 5: Best practice
Dual-homed servers should use different subnets per interface: - eth0: 10.0.0.5/24 (LAN) - eth1: 10.1.0.5/24 (backup/management)
Or use bonding/teaming if redundancy is the goal (both interfaces as one logical interface with same IP).