Static IP Tinc VPN on Debian Wheezy

Install tinc

aptitude install tinc

tinc client create script

#!/bin/bash
#
Version="0.0.8"
#
# automated Tinc configuration of one participant of a static IP VPN ############################################
echo "tinc config configurator"

VPNName="yourtincvpnname123"		# Once set stays the same
VPNSubnet="10.9.8.0/24"			# Once set stays the same
ServerName="Server0123"			# Name of one or more Clients (space separated)
ThisClientName="Client0123"		# Each Client must have a unique Name (Server is created the same way as every other Client)
ThisClientAddress="name.dyndns.tld"	# DNS or IP of this Client
ThisClientPort="655"			# Port of this Client
ThisClientUniqueVpnIp="10.9.8.123"	# Each Client must have a unique static IP

# make needed directories
echo "creating directories ..."
mkdir -v "/etc/tinc/$VPNName/"
mkdir -v "/etc/tinc/$VPNName/hosts/"
touch "/etc/tinc/$VPNName/hosts/tinc.conf"

echo "creating tinc config ..."
echo "Name = $ThisClientName
ConnectTo = $ServerName
Device = /dev/net/tun
Interface = VPN
DeviceType = tap
Mode = switch" > "/etc/tinc/$VPNName/tinc.conf"
#Device = /dev/net/tun // for Linux
#Interface = VPN       // for Windows

cat "/etc/tinc/$VPNName/tinc.conf"
chmod 640 "/etc/tinc/$VPNName/tinc.conf"

echo "creating tinc client file"
echo "Address = $ThisClientAddress
Subnet = $VPNSubnet
Port = $ThisClientPort" > "/etc/tinc/$VPNName/hosts/$ThisClientName"
#Subnet = $VPNSubnet   // virtual subnet

echo "creating ip config file"
echo "#!/bin/sh
ifconfig \$INTERFACE $ThisClientUniqueVpnIp netmask 255.255.0.0" > "/etc/tinc/$VPNName/tinc-up"
chmod +x "/etc/tinc/$VPNName/tinc-up"

# Auto activate This VPN
echo "activating this vpn"
cat /etc/tinc/nets.boot
echo "$VPNName" >> /etc/tinc/nets.boot
cat /etc/tinc/nets.boot

# generate vpn keys
echo "generating public and private vpn keys"
# tincd -n "$VPNName" -K[=BITS]
tincd -n "$VPNName" -K4096

#############!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
echo "Exchange all hosts files (can be done over insecure connections without security flaws)"
#############!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
echo "Debuging:"
echo 'tincd -n "$VPNName" -D -d'