Operating System - Linux
1748264 Members
3836 Online
108760 Solutions
New Discussion юеВ

Having trouble adding a route....

 
MikeL_4
Super Advisor

Having trouble adding a route....

When I try to add a route the Gateway is defaulting to the default...

I've coded the route file as:
# cat /etc/sysconfig/network-scripts/route-eth2
208.14.204.0/24 via 155.90.142.251 dev eth2
155.90.142.0/24 via 155.90.142.251 dev eth2
#

On network restart or reboot, the 208.14.204.0/24 is defined as expected, but the 155.90.142.0/24 defaults to: 0.0.0.0

# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
155.90.142.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
208.14.204.0 155.90.142.251 255.255.255.0 UG 0 0 0 eth2
192.168.35.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
155.90.245.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 0 0 0 eth2
0.0.0.0 155.90.245.251 0.0.0.0 UG 0 0 0 eth0
#

When I try to add it manually I can't get it to set either:

# ip route del 155.90.142.0/24 dev eth2
# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
208.14.204.0 155.90.142.251 255.255.255.0 UG 0 0 0 eth2
192.168.35.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
155.90.245.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 0 0 0 eth2
0.0.0.0 155.90.245.251 0.0.0.0 UG 0 0 0 eth0
#

# ip route add 155.90.142.0/24 gw 155.90.142.251 dev eth2 Error: either "to" is duplicate, or "gw" is a garbage.
#

Or if i try with -net I get:
# ip route add -net 155.90.142.0/24 gw 155.90.142.251 dev eth2
Error: an inet prefix is expected rather than "-net".
#

Not sure what is wrong at this point....
Can anyone tell me where to look ??
2 REPLIES 2
MikeL_4
Super Advisor

Re: Having trouble adding a route....

Thought maybe I had the command syntax wrong, but if I try as follows I get network unreachable....

# ip route add 155.90.142.0/24 via 155.90.142.251 dev eth2
RTNETLINK answers: Network is unreachable
#
Matti_Kurkela
Honored Contributor

Re: Having trouble adding a route....

Your "ip route add" syntax is wrong.

You should use:
ip route add 155.90.142.0/24 via 155.90.142.251 dev eth2

Note: no "-net" and "via" instead of "gw".

Alternatively, you're thinking about the syntax of the older "route" command:

route add -net 155.90.142.0 netmask 255.255.255.0 gw 155.90.142.251 dev eth2


Besides, your post-reboot routing table suggests that your eth2 has an IP address like 155.90.142.x and netmask 255.255.255.0, so the system very reasonably expects to be able to contact all the 155.90.142.* hosts directly via eth2, without using any gateway at all. If this is not true, you either have a wrong netmask on eth2 or the network to which your eth2 is plugged into behaves very strangely.

What kind of netmask does "ifconfig eth2" or "ip addr show dev eth2" display?

MK
MK