I want to save all routes of all routing tables.
I have this script:
#!/bin/bash
DUMP=dump.log
for i in `seq 0 255`;
do
routes="`ip route show table ${i}`"
if [ ! -z "${routes}" ];then
echo "table: ${i}" >> ${DUMP}
echo "${routes}" >> ${DUMP}
echo "" >> ${DUMP}
fi
done
the problems I have with this script are:
- it iterates on all tables, and assume that the only valid table numbers are 0-255, is this a valid assumption?
- is there a simple 1 liner for getting all routes for all tables?
Thanks
Best Answer
It's written in ip route help.