0

i am having a situation where

route add

is not working but if i add that as a static entry in sysconfig/network-scripts/route-eth0

its working

Network details:

IPADDR=198.x.x.1

NETMASK=255.255.255.255

BROADCAST=198.x.x.1

if i add a static route using

route add default gw 192.x.x.254 

it returns SIOCADDRT: No such process

simillary

ping 192.x.x.254

connect: Network is unreachable

strangely if i add it as static entry in route-eth0

route add 192.x.x.254 dev eth0 
route add default gw 192.x.x.254

everything works,i can see default gw in route -n and ping is also working

So what is making the difference here?

2 Answers2

1

You cannot add that route because that default gateway is in different subnet and thus is not reachable.

From man route:

   gw GW  route packets via a gateway.  NOTE: The specified gateway must be reachable first. This usually means that you have to set up a
          static  route  to the gateway beforehand. If you specify the address of one of your local interfaces, it will be used to decide
          about the interface to which the packets should be routed to. This is a BSDism compatibility hack.
Tom Aac
  • 1,097
  • 9
  • 11
  • yes from the command response i understand that,but as mentioned in the post when i added in network-scripts/route-eth0 it accepted that and starts working – chemical X Sep 03 '14 at 10:14
1

IPADDR=198.x.x.1

NETMASK=255.255.255.255

BROADCAST=198.x.x.1

I assume your ip was meant to be 192.x.x.1 (but the explanation will be valid also for 198.x.x.1) and so you create a subnet with an extension of 0 bits (192.x.x.1/32), which means it limits the view to itself

if i add a static route using

route add default gw 192.x.x.254

here you add a gateway outside the extension of your subnet so consequently you get your error:

it returns SIOCADDRT: No such process

for the same reson you can't ping any IP apart from yours (192.x.x.1)

route add 192.x.x.254 dev eth0

route add default gw 192.x.x.254

here you add to your interface eth0 a route to the host 192.x.x.254 and so your subnet (single ip 192.x.x.1) knows where to locate 192.x.x.254, consequently when you add it as gateway everything works. With the previous configuration you were not able to know where 192.x.x.254 was.

SteDf
  • 56
  • 3