User Tools

Site Tools


technical:vpn:tinc

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
technical:vpn:tinc [2023/05/12 07:37] jctechnical:vpn:tinc [2023/05/13 18:14] (current) – external edit 127.0.0.1
Line 1: Line 1:
 <markdown> <markdown>
 # Tinc VPN # Tinc VPN
 +
 ## Install Tinc ## Install Tinc
-Arch Linux + 
-```+### Arch Linux 
 + 
 +```bash
 sudo pacman -S tinc sudo pacman -S tinc
 ``` ```
-Slackware Linux + 
-```+### Slackware Linux 
 + 
 +```bash
 wget https://slackbuilds.org/slackbuilds/15.0/network/tinc.tar.gz wget https://slackbuilds.org/slackbuilds/15.0/network/tinc.tar.gz
 tar xzvf tinc.tar.gz tar xzvf tinc.tar.gz
Line 14: Line 19:
 wget $DOWNLOAD wget $DOWNLOAD
 sudo ./tinc.SlackBuild sudo ./tinc.SlackBuild
-installpkg tinc-1.0.36-x86_64-1_SBo.tgz +sudo installpkg tinc-1.0.36-x86_64-1_SBo.tgz
-## Generate Keys+
 ``` ```
 +
 +## Generate Keys
 +
 +```bash
 tincd -n <netname> -K tincd -n <netname> -K
 ``` ```
 +
 ## Config ## Config
-Copy keys to /etc/tinc/<netname>/ + 
-```+Copy keys to `/etc/tinc/<netname>/
 + 
 + 
 +```bash
 sudo mkdir -p /etc/tinc/<netname>hosts sudo mkdir -p /etc/tinc/<netname>hosts
-cp rsa_key.* /etc/tinc/<netname>+cp rsa_key.* /etc/tinc/<netname>/
 ``` ```
-Create `tinc-up` and `tinc-down` scripts 
  
-/etc/tinc/<netname>/tinc-up+ 
 +Create tinc-up and tinc-down scripts. 
 + 
 +`/etc/tinc/<netname>/tinc-up
 ``` ```
 #!/bin/bash #!/bin/bash
Line 39: Line 54:
 ``` ```
  
-/etc/tinc/<netname>/tinc-down+`/etc/tinc/<netname>/tinc-down
 ``` ```
 #!/bin/bash #!/bin/bash
Line 53: Line 69:
 Create tinc configuration Create tinc configuration
  
-/etc/tinc/<netname>/tinc.conf+`/etc/tinc/<netname>/tinc.conf
 ``` ```
-#!/bin/bash 
-#IP="192.168.70.17/24" 
-#SUB="192.168.70.0/24" 
-#TUN="tinc0" 
-#ip addr add $IP dev $TUN  
-#ip route add $SUB dev $TUN 
-#ip link set $TUN up 
- 
-ip link set tinc0 up 
-ip addr add 192.168.70.17 dev tinc0 
-ip route add 192.168.70.0/24 dev tinc0 
-jc@lilit:/etc/tinc/koba$ cat tinc.conf 
 Name = <hostname>  Name = <hostname> 
 Device = /dev/net/tun Device = /dev/net/tun
Line 77: Line 82:
  
 Add tinc peers Add tinc peers
 +
 +`/etc/tinc/<netname>/hosts/<peer>`
 +
 ``` ```
-Subnet = <tinc_ip_address+Subnet = <peer_ip_address
-Address = <wan_ip_address>+Address = <peer_wan_address>
  
 <Peer's RSA Public Key> <Peer's RSA Public Key>
 ``` ```
 +
 ## Startup ## 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 ## 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 <start|stop|restart>"
 +                exit 1
 +esac
 +
 +exit 0
 +
 +```
 </markdown> </markdown>
 +
technical/vpn/tinc.1683891422.txt.gz · Last modified: by jc