infra/roles/common/templates/pbr_config.j2
2019-06-05 10:41:52 +04:00

13 lines
487 B
Django/Jinja

#!/usr/bin/env bash
if ip rule show | grep -q 'from {{item|ipaddr('address')}}/{{item|ipaddr('prefix')}} lookup tbl_{{nic.key}}'; then
echo "already exists"
else
ip rule add from {{item|ipaddr('address')}}/{{item|ipaddr('prefix')}} lookup tbl_{{nic.key}}
fi
if ip r sh ta all | grep 'default via {{nic.value.default}} dev {{nic.key}} table tbl_{{nic.key}}'; then
echo "already exists"
else
ip route add default via {{nic.value.default}} dev {{nic.key}} table tbl_{{nic.key}}
fi