aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRyan Kavanagh <rak@rak.ac>2021-01-28 20:47:47 -0500
committerRyan Kavanagh <rak@rak.ac>2021-01-28 20:47:47 -0500
commit7cb1b48e980ca9b00abdfe359b623b5cad0deafe (patch)
treed3095e37fb60c8880aa7b17549fd3f84cfa556d3 /bin
parentRename my functions to have prefix my/ (diff)
Added ikeif, a script to add iked-assigned addresses to dummy interfaces
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ikeif17
1 files changed, 17 insertions, 0 deletions
diff --git a/bin/ikeif b/bin/ikeif
new file mode 100755
index 0000000..853c659
--- /dev/null
+++ b/bin/ikeif
@@ -0,0 +1,17 @@
+#!/usr/bin/sudo /bin/sh
+
+for x in 1 3; do
+ if ! ip link show dummy$x >/dev/null 2>&1; then
+ ip link add dummy$x type dummy && ip link set dummy$x up
+ fi
+ SUBNET=$(sudo ikectl show sa | grep -Poh "10.0.$x.\d+/32" | sort -u | sed -e 's@/32@/24@g')
+ CURR=$(ip addr show dev dummy$x label dummy$x:ikeif | grep -Po 'inet \K[\d./]+')
+ if test "x${SUBNET}" != "x${CURR}"; then
+ ip addr add ${SUBNET} label dummy$x:ikeif dev dummy$x
+ if test "x${CURR}" != "x"; then
+ ip addr del "${CURR}" dev dummy$x
+ fi
+ fi
+done
+
+#vim: set ft=sh: