why my syntax of "route" is bad?

I use centos4.2(RHEL4.2). I am a newbie in networking.
When I write : #route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.4 eth1
Centos answer "SIOCADDRT: Network is unreachable". What this message means?
Then, I write : #route add -net 192.168.3.0 netmask 255.255.255.0 eth1
this command is accepted by centos
Then I write :#route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.4 eth1
Now, this command is accepted by centos. why is this command now acceptedand not before?
and #route -n write two lines :
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.3.0     192.168.3.4     255.255.255.0   UG    0      0        0 eth1
192.168.3.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1

The second line is useless. is it possible to have only one line?
gdmoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ravenplCommented:
> When I write : #route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.4 eth1
> Centos answer "SIOCADDRT: Network is unreachable". What this message means?
It means, that currently 192.168.3.4 (the gateway) in unreachable via eth1(ie eth1 has address from outside the 192.168.3.4/24 network )...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ahoffmannCommented:
unfortunately route comes in different syntax flaviours, for example:
  route add -net ip.ip.ip.ip netmask 255.255.255.0 gateway 192.168.3.4 if eth1
  route add -net ip.ip.ip.ip netmask 255.255.255.0 gw 192.168.3.4 dev eth1
  route add -net ip.ip.ip.ip 192.168.3.4
and some more, even variations of the above
Same applies to the del/delete command.

you have to check your docs.
0
Gabriel OrozcoSolution ArchitectCommented:
first: you do not need to define the interface you are using to reach a route unless you have many ways to reach that network using different interfaces.

try your command erasing the "eth1" part =)
#route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.4

now, I see a different problem: you cannot add a route to your own local network!!!

see

a) to be able to reach a different network, you need a gateway on your local network, so you can *see* that gateway.
b) when you assign an ip address on network 192.168.3.0/24 (any ip address, but on that network) then such network becomes your local network. you do not need any gateway to see it. just with trying to access any host on that network, you are able to do so.
c) you are trying to define a route to your local network!!! this is weird and even if linux accepts it, it's not needed.

so, can you explain us what you are trying to do?
0
gdmoAuthor Commented:
thanks to ravepl, to ahoffman, and to redimido. yours three comments were useful for me. I am sorry because I have no been able to understand completely yours answers.
Probably, there is a problem of "flavour" of the "route" command. Besides, as redimido said, it is useless to have a gateway.
I will ask a new question more precise, ans I hope, more clear.
I hesitate to choose which comment I will accept.  I choose the ravenpl comment.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.