# Tinc VPN ## Install Tinc ### Arch Linux ```bash sudo pacman -S tinc ``` ### Slackware Linux ```bash wget https://slackbuilds.org/slackbuilds/15.0/network/tinc.tar.gz tar xzvf tinc.tar.gz cd tinc source tinc.info wget $DOWNLOAD sudo ./tinc.SlackBuild sudo installpkg tinc-1.0.36-x86_64-1_SBo.tgz ``` ## Generate Keys ```bash tincd -n -K ``` ## Config Copy keys to `/etc/tinc//` ```bash sudo mkdir -p /etc/tinc/hosts cp rsa_key.* /etc/tinc// ``` Create tinc-up and tinc-down scripts. `/etc/tinc//tinc-up` ``` #!/bin/bash TUN="" SUB="" IP="" ip link set $TUN up ip addr add $IP dev tinc0 ip route add $SUB dev tinc0 ``` `/etc/tinc//tinc-down` ``` #!/bin/bash TUN="" SUB="" IP="" ip link set $TUN down ip route del $SUB dev $TUN ip addr del $IP dev $TUN ``` Create tinc configuration `/etc/tinc//tinc.conf` ``` Name = Device = /dev/net/tun AddressFamily = ipv4 ConnectTo = Interface = Mode = router Port = ``` Add tinc peers `/etc/tinc//hosts/` ``` Subnet = Address = ``` ## Startup Start tincd ```bash VPN=$(ls /etc/tinc/) for VPN in $VPNS; do echo "Starting tinc daemon for $VPN..." /usr/sbin/tincd -n "$VPN" -d1 --logfile=/var/log/tinc."$VPN" done ``` ## Shell Script ```bash #!/bin/sh VPNS=$(ls /etc/tinc) start () { for VPN in $VPNS; do echo "Starting tinc daemon for $VPN..." /usr/sbin/tincd -n "$VPN" -d1 --logfile=/var/log/tinc."$VPN" done } stop () { for VPN in $VPNS; do echo "Stopping tinc daemon for $VPN..." /usr/sbin/tincd -n "$VPN" -k done } restart () { stop sleep 1 start } case "$1" in ("start") start ;; ("stop") stop ;; ("restart") restart ;; (*) echo "Usage: $0 " exit 1 esac exit 0 ```