Skip to content

Instantly share code, notes, and snippets.

@zenlor
Last active June 8, 2018 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zenlor/c7d100b76915339bce178801f8822417 to your computer and use it in GitHub Desktop.
Save zenlor/c7d100b76915339bce178801f8822417 to your computer and use it in GitHub Desktop.
tinc scripts

tinc config

home will be the name of the network

Main folder:

/etc/tinc/home/

generate key

tincd -n home -K

tinc.conf

Name = nas
ConnectTo = frenz
Device = /dev/net/tun
#!/bin/sh
_FOLDER="/etc/tinc/home"
_NAME="$(grep -Po '(?<=Name = ).*' ${_FOLDER}/tinc.conf)"
_IP_ADDR="$(grep Subnet ${_FOLDER}/hosts/${_NAME} | grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])')"
ip addr del ${_IP_ADDR}/24 dev $INTERFACE
ip link set $INTERFACE down
#!/bin/sh
_FOLDER="/etc/tinc/home"
_NAME="$(grep -Po '(?<=Name = ).*' ${_FOLDER}/tinc.conf)"
_IP_ADDR="$(grep Subnet ${_FOLDER}/hosts/${_NAME} | grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])')"
ip link set $INTERFACE up
ip addr add ${_IP_ADDR}/24 dev $INTERFACE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment