LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-20-2012, 11:08 AM   #1
HarryBoy
Member
 
Registered: Apr 2008
Distribution: MontaVista Linux Version 4.0.1, Professional Edition
Posts: 215

Rep: Reputation: 16
Linux route add question


On my SLES linux computer when I run 'route' from the command line I get the following:


Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.51.56.254 0.0.0.0 UG 0 0 0 eth1
10.51.56.0 * 255.255.255.0 U 0 0 0 eth1
loopback * 255.0.0.0 U 0 0 0 lo
link-local * 255.255.0.0 U 0 0 0 eth0
192.168.200.0 * 255.255.255.0 U 0 0 0 eth0


I am experimenting with adding other routes manually and from this link: http://www.labtestproject.com/linnet/routing.html

I try to do:
route add -host 10.10.0.5 netmask 255.255.0.0 gw 10.51.56.254

But I get the following error:
route: netmask 0000ffff doesn't make sense with host route
Usage: route [-nNvee] [-FC] [<AF>] List kernel routing tables
route [-v] [-FC] {add|del|flush} ... Modify routing table for
blah blah


1. Can you tell me why this is happening based on my route table
2. Also, what is the difference in adding a host route and a network route??

Thanks
 
Old 05-20-2012, 11:37 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,303

Rep: Reputation: Disabled
Quote:
Originally Posted by HarryBoy View Post
I try to do:
route add -host 10.10.0.5 netmask 255.255.0.0 gw 10.51.56.254
You're first telling route that you want to add a host route (-host), that is, a route to a single host. But then you say that the route is actually for a /16 network (netmask 255.255.0.0). Which is it?
 
Old 05-20-2012, 11:54 AM   #3
HarryBoy
Member
 
Registered: Apr 2008
Distribution: MontaVista Linux Version 4.0.1, Professional Edition
Posts: 215

Original Poster
Rep: Reputation: 16
Thanks for your reply, I'new to routes etc.

What I'm trying to do is to create a c++ cgi that, when called, will add routes and remove them from my route table.

So, in this case, is there any example route that I can add to my route table above just for test purposes (So I can add and delete it)

Thanks
 
Old 05-20-2012, 12:29 PM   #4
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,303

Rep: Reputation: Disabled
Quote:
Originally Posted by HarryBoy View Post
So, in this case, is there any example route that I can add to my route table above just for test purposes (So I can add and delete it)
Sure:
Code:
route add -host 192.168.255.254 gw 10.51.56.253
The above will add a route to the IP address 192.168.255.254 via 10.51.56.253. Using -host is the same as specifying a /32 netmask. The same could be accomplished with route add -net 192.168.255.254 netmask 255.255.255.255 gw 10.51.56.253.

The first IP address can be any non-local address, and it's probably best to test with an IP address you know you know won't need to contact. The second address has to be local, but it doesn't necessarily have to be assigned to anything.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
route add question? ddzc Linux - Software 3 11-30-2006 03:41 PM
Question about route add default ppp0??? marsh58 Linux - Networking 3 06-26-2006 08:59 AM
I am not able to add a new route to my route table using route command prashanth s j Linux - Networking 2 09-03-2005 04:34 AM
Route add in Linux 8.0 aviraje2000 Linux - Newbie 1 03-02-2004 06:36 AM
Route Add Question sideveloper Linux - Networking 3 01-16-2004 11:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration