Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-31-2005, 11:45 PM   #1
LQ Newbie
Registered: Aug 2003
Location: Ballarat, Victoria, Australia
Distribution: Redhat 9.0
Posts: 14

Rep: Reputation: 0
Adding entries to route table in C?


Just wondering if any of you know if it's possible to check for and add if non-existant, an entry to the kernel routing table. I'm working on some RH9 machines, and for some reason the multicast route isnt there.

I know I could just tell the user to add them all manually, but it would be much easier if the program could check and do it for them if need be.

Cant seem to find much on it in Google either, but I may be giving it bad search terms. I'll keep looking all the same.

Any ideas are greatly appreciated.

Old 04-01-2005, 01:05 AM   #2
Registered: Mar 2005
Location: São Paulo - Brazil
Distribution: Debian
Posts: 45

Rep: Reputation: 15
I'm not a great programmer, but I think this might work:

system("route add -net x.x.x.x/x");
But you may also find some library to do that or you could make a script that runs in the boot time...
Old 04-04-2005, 02:42 PM   #3
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 657Reputation: 657Reputation: 657Reputation: 657Reputation: 657Reputation: 657
I think this would be best done with a script, perl or bash.

Something like:
route | grep ' \*' || route <arguments>

If grep doesn't find a match, the route command at the end is executed. It is skipped if there is a match.
I just copied a line of interest from the output of the route command, and backslashed the asterisk in this example.


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
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
How to save routing table entries? drgowans Linux - Networking 6 09-23-2003 02:35 PM
Route table loses entries filth Linux - Networking 3 05-05-2003 05:27 PM
Working with 'route' and unwanted route entries pioniere Linux - Networking 6 02-05-2003 12:14 PM
Adding persistent(permanent) route entries on Red hat Linux 7.1 sram Linux - Networking 1 02-08-2002 10:07 AM

All times are GMT -5. The time now is 04:39 AM.

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