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. |
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 |
All times are GMT -5. The time now is 03:31 PM. |