0

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:

  1. it iterates on all tables, and assume that the only valid table numbers are 0-255, is this a valid assumption?
  2. is there a simple 1 liner for getting all routes for all tables?

Thanks

2
  • 2
    ip route show table all
    – cburn11
    Aug 26, 2018 at 11:36
  • @cburn11: why not make an answer?
    – Thomas
    Aug 26, 2018 at 14:23

1 Answer 1

5
ip route list table all

It's written in ip route help.

1
  • You should remove the period after all in your example.
    – JFlo
    Jun 27, 2019 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.