diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2020-01-23 04:29:12 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2020-01-23 05:57:01 +0100 |
commit | 7641a5d5d152db349082b1d0ec93a40888b2ef8e (patch) | |
tree | 3f80c14c0e50b187a6698346cf8cffb9c5200154 /roles/common/templates/etc/network | |
parent | 456e09fa40d01b70ac1788d0338fba00079e4121 (diff) |
Convert firewall to nftables.
Debian Buster uses the nftables framework by default.
Diffstat (limited to 'roles/common/templates/etc/network')
-rwxr-xr-x | roles/common/templates/etc/network/if-up.d/ipsec.j2 | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/roles/common/templates/etc/network/if-up.d/ipsec.j2 b/roles/common/templates/etc/network/if-up.d/ipsec.j2 index caa5129..9f183d3 100755 --- a/roles/common/templates/etc/network/if-up.d/ipsec.j2 +++ b/roles/common/templates/etc/network/if-up.d/ipsec.j2 @@ -25,10 +25,9 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin # Only the device with the default, globally-scoped route, is of # interest here. -ip="$( ip -4 -o route show to default scope global \ - | sed -nr '/^default via (\S+) dev (\S+).*/ {s//\2 \1/p;q}' )" -[ "${ip% *}" = "$IFACE" ] || exit 0 -ip="${ip##* }" +iface="$( ip -o route show to default scope global \ + | sed -nr '/^default via \S+ dev (\S+).*/ {s//\1/p;q}' )" +[ "$iface" = "$IFACE" ] || exit 0 vip="{{ ipsec[inventory_hostname_short] }}" vsubnet="{{ ipsec_subnet }}" @@ -39,9 +38,9 @@ case "$MODE" in # in the absence of xfrm lookup (i.e., when there is no # matching IPsec Security Association). ip route replace prohibit "$vsubnet" proto static || true - ip route replace table 220 to "$vsubnet" via "$ip" dev "$IFACE" proto static src "$vip" || true + ip route replace table 220 to "$vsubnet" dev "$IFACE" proto static src "$vip" || true ;; - stop) ip route del table 220 to "$vsubnet" via "$ip" dev "$IFACE" proto static src "$vip" || true + stop) ip route del table 220 to "$vsubnet" dev "$IFACE" proto static src "$vip" || true ip route del prohibit "$vsubnet" proto static || true ip address del "$vip/32" dev "$IFACE" scope global || true esac |