LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 07-13-2009, 04:53 AM   #1
shreeman
LQ Newbie
 
Registered: Jul 2009
Posts: 1

Rep: Reputation: 0
Flushing Linux kernel routing table - server got shutdown


i have a requirement in which i have to flush kernel routing table (main table) and then populate it with net and host address from /etc/sysconfig/static-routes files on Linux RHEL5.2 release (64bit)servers. i tried running this command "ip route flush table main proto boot" at command prompt but server got shutdown immediatley after running this command. Also i tried a script to delete each entry from kernel routing table. After the execution of script server got shutdown.
Script:-

echo "Flushing routing table"
ip route show table main | while read ROUTES; do
ip route del $ROUTES
done
echo "Done Flushing !!"
echo "Show routing table content"
`ip route show table main`
echo "Done Showing content !!"

output:-
Flushing routing table
Done Flushing !!
Show routing table content
Done Showing content !!

please suggest how to flush the Linux kernel routing table.
 
Old 07-13-2009, 05:51 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You might want to read the code in ifdown-route & ifup-route. Wouldn't it be a lot easier to shut down the interface (ifdown <interface>). That will flush the routes. Your problem may be due to shutting down the local host route.

From browsing the script, running "ifroute-up" sets an ACTION variable to "replace". This sounds like you can run ifroute-up to flush and replace the routes.

I'm using SuSE, but there may be a similar script in rhel. Try grepping files in /etc/ for the string "ip route" or better yet "static-routes". The script you find may do exactly what you want.

This webpage has examples of using "ip route flush".
http://www.physics.umd.edu/pnce/pcs-...oute-hack.html

Last edited by jschiwal; 07-13-2009 at 05:53 AM.
 
  


Reply



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
In Linux, How to read and modify Kernel IP routing table entries from a c program sakthivelbatusai Linux - Networking 1 03-29-2007 06:36 AM
Bypass kernel routing table hk_linux Linux - Networking 2 09-01-2006 09:55 AM
Kernel IP routing table question AlexBell Linux - Networking 2 06-01-2005 06:09 AM
Unable to update kernel routing table TrashCanMan Linux - Wireless Networking 2 03-07-2004 04:03 AM
editing Kernel IP Routing Table hamish Linux - Networking 0 10-06-2003 04:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 10:41 PM.

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