First we need to install the prereqs to build the tinc pakage.
sudo apt install build-essential automake libssl-dev liblzo2-dev libbz2-dev zlib1g-dev git texinfo
Next, create a tinc
user and give them sudo ablity
adduser tinc
adduser tinc sudo
if we dont want to have to enter a password everytime we sudo
visudo
(as root)- add the line
%sudo ALL=(ALL) NOPASSWD: ALL
(make sure thats the only line that modifies the %sudo group as any otherline may override this one.)
Now, we need to clone the git repository to our local machine
git clone git@github.com:logbie/tinc.git
(you will need to deploy key)
next we need to Build the package
sudo sh ./configure
sudo make
autoreconf -f -i
(only if there is an error while running make)sudo make install
First create the tinc directories
sudo mkdir -p /usr/local/etc/tinc/lgbenet/hosts/
sudo mkdir -p /usr/local/var/run/
Next, Start with the tinc.config
file
First change to the directory
cd /
(get back to root)cd /usr/local/tinc/lgbenet/
Then open tinc.conf
we will use nano but you can use your editor of choice
sudo nano tinc.conf
on the base node (the one we want to use a a server) paste
Name = lgbe01
Device = /dev/net/tun
AddressFamily = ipv4
on all other nodes the file should look like this (the addition is in bold text)
Name = lgbe02
Device = /dev/net/tun
AddressFamily = ipv4
ConnectTo = lgbe01
For every node we want we need two things a keypair and a hosts file
to make a keypair type in the command
sudo tincd -n lgbenet -K 4096
(where lgbenet
is the network name)
secondly, the hosts file stored under the /hosts directory in your root tinc network folder it should contain.
Address = Your physical ip address
Subnet = Your virtual ip address
sudo tincd -n lgbenet -K 4096
if you have followed the above directions this should automatically
append the public key to your hosts file,
Create the tinc-up file
#!/bin/sh
ip link set $INTERFACE up
ip addr add 192.168.100.209 dev $INTERFACE
ip route add 192.168.100.0/24 dev $INTERFACE
Next, Create a tinc-down file
#!/bin/sh
ip route del 192.168.100.0/24 dev $INTERFACE
ip addr del 192.168.100.209 dev $INTERFACE
ip link set $INTERFACE down
[Unit]
Description=Tinc net linodeVPN
After=network.target[Service]
Type=simple
WorkingDirectory=/usr/local/etc/tinc/lgbenet
ExecStart=/usr/local/sbin/tincd -n lgbenet -D -d3
ExecReload=/usr/local/sbin/tincd -n lgbenet -kHUP
TimeoutStopSec=5
Restart=always
RestartSec=60[Install]
WantedBy=multi-user.target
enable the service to start when linux boots
sudo systemctl enable tinc.service