why my syntax of "route" is bad?

Posted on 2006-04-01
Last Modified: 2008-01-09
I use centos4.2(RHEL4.2). I am a newbie in networking.
When I write : #route add -net netmask gw eth1
Centos answer "SIOCADDRT: Network is unreachable". What this message means?
Then, I write : #route add -net netmask eth1
this command is accepted by centos
Then I write :#route add -net netmask gw 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   UG    0      0        0 eth1   U     0      0        0 eth1

The second line is useless. is it possible to have only one line?
Question by:gdmo
    LVL 43

    Accepted Solution

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

    Expert Comment

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

    you have to check your docs.
    LVL 19

    Expert Comment

    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 netmask gw

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


    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 (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?

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
    Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now