Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Linux computer and an eth0 interface with 2 IPs:

ip : 10.10.1.1
mask : 255.128.0.0
gw : 0.0.0.0

ip : 10.22.32.1
mask : 255.255.255.0
gw : 10.22.32.254

I would like to add a specific gateway for network 10.22.0.0/16, so this is what I did:

route add -net 10.22.0.0/16 gw 10.22.32.254 dev eth0

This doesn't work, and I can't reach machines on 10.10.0.0 anymore. Here is the routing table:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 eth0
10.0.0.0        0.0.0.0         255.128.0.0     U     1      0        0 eth0
10.22.0.0       10.22.32.254    255.255.0.0     UG    0      0        0 eth0
10.22.32.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0

Does it fail because 10.22.0.0/16 is a subpart of 10.10.0.0/9?

share|improve this question
    
0.0.0.0 means directly connected, is 10.10.0.0 behind a router? –  NickW May 22 at 9:08
    
Yes, the 10.10.0.0 network is directly reachable (no routing needed) –  user220746 May 22 at 9:10
    
Route will tend to chose the closest match, so only 10.22.0.0 - 10.22.255.255 will be routed towards 10.22.32.254. Otherwise it would chose 0.0.0.0. I'd check if 1. the machines in 10.10.0.0 have any routes, and 2. that 10.22.32.254 is configured correctly to route. –  NickW May 22 at 9:15
    
There's no doubt that 10.22.32.254 is correctly configured and machines in 10.10.0.0 don't have routes. I also thought that it took the closest match, but it doesn't seem to do so :( –  user220746 May 22 at 9:18
    
When did the problem start? I'm wondering if the issue isn't due to the fact that the 10.22 IP falls into the 10.10 network, so when it sends traffic, it will fall back to originating from 10.10.1.1 . –  NickW May 22 at 9:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.