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’ve been looking around before asking,

On the linux box there are 2 interfaces:

Bond0: inet addr:170.242.57.113  Bcast:170.242.57.255  Mask:255.255.255.0
Eth4    : inet addr:172.21.136.124  Bcast:172.21.137.255  Mask:255.255.254.0

Because eth4 is on a different network, I want to setup a new route, therefore

used route-eth4 
ADDRESS0=172.21.136.0
NETMASK0=255.255.254.0
GATEWAY0=172.21.137.251

But this failled, looked into ifup and worked out that /etc/sysconfig/network-scripts/ifup-routes was the script setting up the routing, issuing the following command

ip route  add 172.21.136.0/23 via 172.21.137.251 dev eth4 
RTNETLINK answers: File exists

Looks like the route can’t be added for /23

But works if I do it with 2 /24

   ip route  add 172.21.136.0/24 via 172.21.137.251 dev eth4                                                                                 
    ip route  add 172.21.137.0/24 via 172.21.137.251 dev eth4 





netstat –nr

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
172.21.137.0    172.21.137.251  255.255.255.0   UG        0 0          0 eth4
172.21.136.0    172.21.137.251  255.255.255.0   UG        0 0          0 eth4
170.242.57.0    0.0.0.0         255.255.255.0   U         0 0          0 bond0
172.21.136.0    0.0.0.0         255.255.254.0   U         0 0          0 eth4
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth4
0.0.0.0         170.242.57.251  0.0.0.0         UG        0 0          0 bond0

It works fine and I don’t understand why it’s not working for the /23

Address:   172.21.136.124        10101100.00010101.1000100 0.01111100
Netmask:   255.255.254.0 = 23    11111111.11111111.1111111 0.00000000
Wildcard:  0.0.1.255             00000000.00000000.0000000 1.11111111
=>
Network:   172.21.136.0/23       10101100.00010101.1000100 0.00000000 (Class B)
Broadcast: 172.21.137.255        10101100.00010101.1000100 1.11111111
HostMin:   172.21.136.1          10101100.00010101.1000100 0.00000001
HostMax:   172.21.137.254        10101100.00010101.1000100 1.11111110
Hosts/Net: 510                   (Private Internet)

Any idea?

share|improve this question
4  
Stop. Please go read How does Subnetting Work. Keep reading until you understand why you got the "File Exists" error. I'm not trying to be mean, but you're apparently lacking a bit in understanding IP Subnets. –  Chris S Oct 21 '11 at 15:47

2 Answers 2

The /23 is already in your table...

netstat \u2013nr

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
172.21.137.0    172.21.137.251  255.255.255.0   UG        0 0          0 eth4
172.21.136.0    172.21.137.251  255.255.255.0   UG        0 0          0 eth4
170.242.57.0    0.0.0.0         255.255.255.0   U         0 0          0 bond0
172.21.136.0    0.0.0.0         255.255.254.0   U         0 0          0 eth4 <----------
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth4
0.0.0.0         170.242.57.251  0.0.0.0         UG        0 0          0 bond0

Also keep in mind that ip route add 172.21.136.0/23 via 172.21.137.251 dev eth4 is a bit non-sensical since 172.21.137.251 is in 172.21.136.0/23

share|improve this answer
    
But how does it know to route to the gateway 172.21.137.251 ? –  rnoooo Oct 21 '11 at 14:29
    
@rnooooo, remove the old entry and it will work –  Mike Pennington Oct 21 '11 at 14:31
    
I can see it working before –  rnoooo Oct 21 '11 at 14:36
    
ip route get 172.21.136.23 172.21.136.23 dev eth4 src 172.21.136.124 –  rnoooo Oct 21 '11 at 14:36
    
But this tell me that it's going to use eth4 to route this ip, but I can't what will be the gateway, how does the box work it out? –  rnoooo Oct 21 '11 at 14:37

It works fine and I don’t understand why it’s not working for the /23

Because it's already there - this is what RTNETLINK answers: File exists is telling you.

your netstat -rt output contains this route:

172.21.136.0    0.0.0.0         255.255.254.0   U         0 0          0 eth4

which is conflicting with ip route add 172.21.136.0/23 via 172.21.137.251 dev eth4.

share|improve this answer
    
But how does it know to route to the gateway 172.21.137.251, not sure to understand the meaning of 0.0.0.0 –  rnoooo Oct 21 '11 at 14:30
4  
0.0.0.0 is used for a gatway when the network is local. You don't need a gateway for that network you are connected to it. –  Zoredache Oct 21 '11 at 15:42
    
Fwiw I don't think File exists is an acceptable error message. If it is a route that already exists, why not use Route exists as an error message? If not, which file is it that already exists? –  moritz Jul 7 '12 at 17:37

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.