ip_bar=192.168.1.2
mask=24
+echo [STEP] Create network namespaces
+
+ip netns add ping.test1
+ip netns add ping.test2
+
+cleanup_hook() {
+ ip netns del ping.test1
+ ip netns del ping.test2
+}
+
echo [STEP] Initialize two nodes
tinc foo <<EOF
# shellcheck disable=SC2016
create_script foo tinc-up "
- ip netns add ping.test1
ip link set dev \$INTERFACE netns ping.test1
ip netns exec ping.test1 ip addr add $ip_foo/$mask dev \$INTERFACE
ip netns exec ping.test1 ip link set \$INTERFACE up
# shellcheck disable=SC2016
create_script bar tinc-up "
- ip netns add ping.test2
ip link set dev \$INTERFACE netns ping.test2
ip netns exec ping.test2 ip addr add $ip_bar/$mask dev \$INTERFACE
ip netns exec ping.test2 ip link set \$INTERFACE up
wait_script bar hosts/foo-up
ip netns exec ping.test1 ping -W1 -c3 $ip_bar
-
-echo [STEP] Clean up
-
-ip netns del ping.test2
-ip netns del ping.test1
(
set +ex
+ if command -v cleanup_hook 2>/dev/null; then
+ echo >&2 "Cleanup hook found, calling..."
+ cleanup_hook
+ fi
+
stop_all_tincs
# Ask nicely, then kill anything that's left.