6 stdbuf -oL ip monitor route | (
9 read -t 1 -N 100000 || true # clear stdin
10 for int in $( sed -n '/# local/,$ { /^[^#]/ s/.* // p }' /etc/iproute2/rt_tables )
14 tab=$(ip -"$proto" route list table "$int" match default |
15 sed 's/\(dev [^ ]*\) .*/\1/')
16 def=$(ip -"$proto" route list match default |
17 sed -n '/dev '"$int"'/ {
18 s/\(dev [^ ]*\) .*/\1/
21 if [ "x$def" != "x$tab" ]
23 ip -"$proto" route flush table "$int" || true
24 ip -"$proto" route add $def table "$int" || true
25 ip -"$proto" route add $(
26 ip -"$proto" route list proto kernel |
27 sed -n '/dev '"$int"'/ {
28 s/\(dev [^ ]*\) .*/\1/
32 ) table "$int" || true
33 ip -"$proto" rule del table "$int" || true
34 ip -"$proto" rule add from $(
35 ip -"$proto" addr show "$int" scope global | sed -n '