1

As part of a script, I'd like to temporarily add a route table for the duration of the script.

ip route add default via "${ip}" dev "${dev}" table "${table}"
.
.
.
ip route flush table "${table}"

If there a good way to programmatically find an unused table ID to use for this purpose?

1
i=1
while [ "$(ip route show table "$i")" ]; do i=$((i+1)); done
# $i is your free table

some shell wizard may make it better ;-)

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.