Error adding static route

Hi all

i have a simple question here
I'm kind of newbie on solaris development
currently i'm trying to add static route to solaris environment
and i got error, each time i add this static route to it

btw this is my command :

root@xxxxxx # ping 1.2.3.1
1.2.3.1 is alive

echo  "1.2.3.0 255.255.255.0" >> /etc/netmasks

root@xxxxxx # route add net 1.2.3.0 1.2.3.1          
add net 1.2.3.0: gateway 1.2.3.1: Network is unreachable

root@xxxxxx # netstat -rn

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface 

doesnt show anything about 1.2.3.0 segment

what's wrong with the command ?

use route add -net ...

Hi incredible

I have add '-' in the front of net
but the result is still the same ..

need your help
...

if this is your default route, use route add default <route_IP> and also include the entry<route_IP> in the /etc/defaultrouter file
if your defaultgateway is already present and you want to add a static route, use this:-
EG

route add -net 172.16.10.0 255.255.255.0 172.16.17.224

Hi incredible

i allready have default gateway
i run the command you suggested
but the result is still the same

root@xxxxxxxx # route add -net 1.2.3.0 255.255.255.0 1.2.3.1
add net 1.2.3.0: gateway 255.255.255.0: Network is unreachable

Probably needs the "count" field.

For example:
route add net 1.2.3.0 1.2.3.1 2

Hi ..

I've tried it
and the result is still the same ..

root@xxxxxx # route add -net 1.2.3.0 255.255.255.0 1.2.3.1 4
add net 1.2.3.0: gateway 255.255.255.0: Network is unreachable
root@xxxxxx # route add -net 1.2.3.0 255.255.255.0 1.2.3.1 2
add net 1.2.3.0: gateway 255.255.255.0: Network is unreachable

please help me ...

can you check the netmask file? should have a tab in between the 2 entries and not space.
btw, you mentioned that your default route is there?? but how come the netstat -rn returns nothing? should not be the case.

Hi i have look at netmask file
and it was using space instead of tab

now i got another questions ?

Do i have to restart the network system ?
how could i do that ?

Ensure to have a tab space.
If you're using Solaris 10

svcadm restart svc:/milestone/network:default

If you're using Solaris 9 and below, you may use

pkill -HUP inetd

Hi ...

its still on the same result
i put all output here

bash-3.00# netstat -rn

Routing Table: IPv4
  Destination           Gateway           Flags  Ref   Use   Interface
-------------------- -------------------- ----- ----- ------ ---------
192.168.252.0        192.168.252.155      U         1      0  e1000g0
224.0.0.0            192.168.252.155      U         1      0  e1000g0
127.0.0.1            127.0.0.1            UH        4     81  lo0

bash-3.00# more /etc/netmasks
#
# The netmasks file associates Internet Protocol (IP) address
# masks with IP network numbers.
#
#       network-number  netmask
#
# The term network-number refers to a number obtained from the Internet Network
# Information Center.
#
# Both the network-number and the netmasks are specified in
# "decimal dot" notation, e.g:
#
#               128.32.0.0 255.255.255.0
#
192.168.252.0   255.255.255.0
172.168.192.0   255.255.255.0
bash-3.00# route add -net 172.168.192.0 255.255.255.0 172.168.192.1 2
add net 172.168.192.0: gateway 255.255.255.0: Network is unreachable
bash-3.00#

I still don't see your default gateway..

here it is :

root@xxxx # less /etc/netmasks 
#
# The netmasks file associates Internet Protocol (IP) address
# masks with IP network numbers.
# 
#       network-number  netmask
#
# The term network-number refers to a number obtained from the Internet Network
# Information Center.
#
# Both the network-number and the netmasks are specified in
# "decimal dot" notation, e.g:
#
#               128.32.0.0 255.255.255.0
#
1.4.125.0     255.255.255.0
2.15.246.0   255.255.255.0
root@xxxx # less /etc/defaultrouter 
1.4.125.1
root@xxxx # netstat -nr

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface 
-------------------- -------------------- ----- ----- ---------- --------- 
default              1.4.125.1          UG        1        227           
1.4.125.0          1.4.125.123        U         1        505 ce0       
224.0.0.0            1.4.125.123        U         1          0 ce0       
127.0.0.1            127.0.0.1            UH       36      74784 lo0       
root@xxxx # ping 2.15.246.253
no answer from 2.15.246.253
root@xxxx # ping 2.15.246.1  
2.15.246.1 is alive
root@xxxx # traceroute 2.15.246.1
traceroute to 2.15.246.1 (2.15.246.1), 30 hops max, 40 byte packets
 1  1.4.125.3 (1.4.125.3)  0.317 ms  0.252 ms  0.233 ms
 2  1.4.113.75 (1.4.113.75)  0.552 ms  0.431 ms  0.421 ms
 3  1.4.113.21 (1.4.113.21)  0.471 ms  0.477 ms  0.509 ms
 4  1.4.113.142 (1.4.113.142)  3.176 ms  3.174 ms  3.120 ms
 5  1.1.126.121 (1.1.126.121)  3.392 ms  3.227 ms  3.321 ms
 6  1.1.126.50 (1.1.126.50)  3.303 ms  3.367 ms  3.306 ms
 7  2.15.246.1 (2.15.246.1)  3.359 ms  3.481 ms  3.373 ms
root@xxxx # traceroute 2.15.246.253
traceroute to 2.15.246.253 (2.15.246.253), 30 hops max, 40 byte packets
 1  1.4.125.3 (1.4.125.3)  0.352 ms  0.228 ms  0.246 ms
 2  1.4.113.75 (1.4.113.75)  0.526 ms  0.439 ms  0.450 ms
 3  1.4.113.13 (1.4.113.13)  0.545 ms  0.482 ms  0.466 ms
 4  1.4.113.138 (1.4.113.138)  3.326 ms  3.153 ms  3.128 ms
 5  1.2.201.138 (1.2.201.138)  3.293 ms  3.302 ms  3.304 ms
 6  1.1.126.50 (1.1.126.50)  3.282 ms  3.363 ms  3.232 ms
 7  1.6.4.7 (1.6.4.7)  3.429 ms  3.377 ms  3.384 ms
 8  * * *
 9  *^C
root@xxxx # route add -net 2.15.246.0 255.255.255.0 2.15.246.1 2
add net 2.15.246.0: gateway 255.255.255.0: Network is unreachable

Assuming this is Solaris 10, we need to identify the netmask field or it gets interpreted as the gateway field?

route add -net 2.15.246.0 -netmask 255.255.255.0 2.15.246.1 2

Hi,

Is the Gateway address your interface IP? If so then what is the subnet set in it?

//Jack

You cant add a route to a network where the gateway is part of the same subnet.
Using your example:

route add -net 2.15.246.0 255.255.255.0 2.15.246.1

You are giving it a route to the 2.15.246.0 network via the gateway 2.15.246.1.
But if it already knows how to get the 2.15.246.1 then it already knows how to get to the whole net (if your subnet is 255.255.255.0) so it wont allow the route.

Also I believe, your gateway needs to be on a network that is already specifically listed in the routing table, NOT just available from the default route (otherwise it assumes the default router can handle it, because thats its job)

It seems that the router 1.1.126.50 has a different subnetmask for the 2.15.246.x network as its routing .1 correctly but not .253 - Im pretty sure you cant override this route using the local routing table.

Also you cannot always use "ping" to test routes. "ping" uses "icmp" NOT "ip" and therefore is not constrained to the same routing protocols (icmp can be redirected amoungst other things).