
正文
Tinc VPN
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
服务端配置
安装
$ apt-get install tinc
配置
$ mkdir -p /etc/tinc/dock/hosts$ cd /etc/tinc/dock
配置 tinc.conf
$ vim /etc/tinc/dock/tinc.confName=dockserverInterface=dockMode=switchTCPOnly=yesPort=12345PrivateKeyFile=/etc/tinc/dock/rsa_key.priv
配置 tinc-up
$ vim /etc/tinc/dock/tinc-up#!/bin/shifconfig $INTERFACE 192.168.0.1 netmask 255.255.255.0
配置 tinc-down
$ vim /etc/tinc/dock/tinc-down#!/bin/shifconfig $INTERFACE down
Service 配置 dockserver,其中 Address 为服务端的实际 IP 地址
$ vim /etc/tinc/dock/hosts/dockserverCompression=9Subnet=192.168.0.1/32Address=x.x.x.xPort=54321
修改权限
$ chmod 755 /etc/tinc/dock/{tinc-down,tinc-up}
服务端生成 key
$ cd /etc/tinc/$ tincd -n dock -KGenerating 2048 bits keys:...............................................+++ p............................................................+++ qDone.Please enter a file to save private RSA key to [/etc/tinc/vpn/rsa_key.priv]:Please enter a file to save public RSA key to [/etc/tinc/vpn/hosts/vpnserver]:
客户端配置
安装
$ apt-get install tinc
配置
$ mkdir -p /etc/tinc/dock/hosts$ cd /etc/tinc/dock
创建 tinc.conf 配置文件
$ vim /etc/tinc/dock/tinc.confName=client01ConnectTo=dockserverInterfce=dockMode=switchTCPOnly=yesPrivateKeyFile=/etc/tinc/dock/rsa_key.priv
创建 tinc-down
$ vim /etc/tinc/dock/tinc-down#!/bin/shifconfig $INTERFACE down
创建 tinc-up
$ vim /etc/tinc/dock/tinc-up#!/bin/shifconfig $INTERFACE 192.168.0.2 netmask 255.255.255.0
创建 clinent01 配置文件
$ vim /etc/tinc/dock/hosts/client01Compression=9Subnet=192.168.0.2/32
修改权限
$ chmod 755 /etc/tinc/dock/{tinc-down,tinc-up}
把服务端的 dockserver 拷贝到客户端
$ scp root@x.x.x.x:/etc/tinc/dock/hosts/dockserver /etc/tinc/dock/hosts/dockserver
客户端生成 key
$ tincd -n dock -KGenerating 2048 bits keys:................................................+++ p......+++ qDone.Please enter a file to save private RSA key to [/etc/tinc/vpn/rsa_key.priv]:Please enter a file to save public RSA key to [/etc/tinc/vpn/hosts/vpnclient01]:
把客户端生成的配置文件拷贝到服务端
$ scp /etc/tinc/dock/hosts/client01 root@x.x.x.x:/etc/tinc/dock/hosts/client01
启动和关闭
$ tincd -n dock #启动tinc vpn$ tincd -n dock -k #关闭tinc vpn
启动完成后查看 ifconfig 后会有 dock 的网卡参数
$ ifconfigdock Link encap:Ethernet HWaddr c2:f1:b3:6d:7a:f2 inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:5 errors:0 dropped:0 overruns:0 frame:0 TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:950 (950.0 B) TX bytes:280 (280.0 B)
客户端为 192.168.0.2 ,如果不互通可以把 tincd 启动在前台查看日志
$ tincd -n dock -D -d 5





