LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 04-01-2005, 12:45 AM   #1
kuronai
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?


Hi,

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.

Cheers
 
Old 04-01-2005, 02:05 AM   #2
xstefanox
Member
 
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:

Code:
.
.
.
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, 03:42 PM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

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

Something like:
route | grep '192.168.1.0 \* 255.255.255.0' || 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.
 
  


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


All times are GMT -5. The time now is 11:56 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration