用户工具

站点工具


freebsd:tinc
no way to compare when less than two revisions

差别

这里会显示出您选择的修订版和当前版本之间的差别。


前一修订版
freebsd:tinc [2021/08/18 11:13] (当前版本) – [启动] Hshh
行 1: 行 1:
 +====== Tinc for FreeBSD ======
  
 +由于OpenVPN到国外的连通性出现问题后, 考虑到OpenVPN+proxy类再加密会有性能损失, 所以改用 [[http://www.tinc-vpn.org/|Tinc]].
 +
 +Ports里面的Tinc是只有Stable版本, 但是有些打算用到新功能在prerelease版本内, 所以自己编译.
 +需要依赖openssl和lzo, 现在ports里面安装 security/openssl 和 archivers/lzo2
 +./configure --prefix=/usr/local/tinc --with-openssl=/usr/local --with-lzo=/usr/local
 +make all install
 +以上简略带过.
 +
 +==== 服务端 ====
 +
 +安装好后的tinc在/usr/local/tinc
 +执行以下命令为服务器生成密钥
 +<code>
 +/usr/local/tinc/sbin/tinc init server
 +</code>
 +
 +配置文件在/usr/local/tinc/etc/tinc, 进入该目录
 +编辑tinc.conf
 +<code>
 +Name = server
 +Device = /dev/tun10
 +TunnelServer = yes
 +</code>
 +
 +编辑tinc-up
 +<code>
 +#!/bin/sh
 +/sbin/ifconfig tun10 up
 +/sbin/ifconfig tun10 inet 10.255.1.1/24
 +/etc/rc.d/pf reload
 +</code>
 +
 +编辑hosts/server, 在顶部添加
 +<code>
 +Compression = 10
 +Subnet = 0.0.0.0/0
 +</code>
 +
 +__复制 client 端的 etc/tinc/hosts/client 到 etc/tinc/hosts/, 该步骤可以先配置客户端后再完成.__
 +
 +==== 客户端 ====
 +
 +生成密钥
 +<code>
 +tinc init client
 +</code>
 +
 +配置 etc/tinc/tinc.conf
 +<code>
 +Name = client
 +Interface = tun10
 +ConnectTo = server
 +MaxTimeout = 5
 +</code>
 +
 +配置 etc/tinc/hosts/client, 头部添加
 +<code>
 +Compression = 10
 +Subnet = 10.255.1.1
 +</code>
 +
 +复制 server 端的 etc/tinc/hosts/server 到 etc/tinc/hosts/, 修改头部
 +<code>
 +Address = server_域名或者ip地址
 +Compression = 10
 +-----BEGIN RSA PUBLIC KEY-----
 +.....
 +</code>
 +
 +==== NAT ====
 +
 +pf.conf
 +<code>
 +scrub all no-df random-id fragment reassemble
 +nat on $ext_if from { 10.255.1/24 } to any -> ($ext_if)
 +</code>
 +
 +==== 启动 ====
 +
 +附件为FreeBSD rc.d 脚本, 用于启动 tincd
 +
 +调试可采用 tincd -D -d3 或 tincd -D -d4
 +
 +{{:freebsd:tincd|FreeBSD tincd rc.d 启动脚本}}
 +
 +{{tag>freebsd tinc vpn}}
freebsd/tinc.txt · 最后更改: 2021/08/18 11:13 由 Hshh