avoiding duplicate IPs in tinc scripts
Lars Kruse
lists at sumpfralle.de
Wed Aug 1 11:43:52 CEST 2018
Hello Hamish,
Am Wed, 1 Aug 2018 11:42:58 +1000
schrieb Hamish Moffatt <hamish at moffatt.email>:
> Currently I have the local tinc node's VPN IP in both the tinc-up script as
> well as in its hosts/$NODE file Subnet setting. Can this be avoided, to
> simplify deployment?
I use the following tinc-up script.
It determines the local node's host filename and parses all "Subnet" lines
without a slash (indicating networks) lines from it.
#!/bin/sh
set -eu
MY_HOST_FILE="/etc/tinc/$NETNAME/hosts/$NAME"
grep -i "^Subnet[^/]*$" "$MY_HOST_FILE" | cut -f 2 -d = | tr -d " " \
| while read -r my_ip; do
ip address add "${my_ip}/24" dev "$INTERFACE"
done
ip link set "$INTERFACE" up
The following details are imperfect:
* Subnet lines with a single-host prefix length ("/32") are ignored, too
* the network prefix length is part of the script
(there is no way to determine it)
Maybe this helps ...
Cheers,
Lars
More information about the tinc
mailing list