用户工具

站点工具


freebsd:tinc

Tinc for FreeBSD

由于OpenVPN到国外的连通性出现问题后, 考虑到OpenVPN+proxy类再加密会有性能损失, 所以改用 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 执行以下命令为服务器生成密钥

/usr/local/tinc/sbin/tinc init server

配置文件在/usr/local/tinc/etc/tinc, 进入该目录 编辑tinc.conf

Name = server
Device = /dev/tun10
TunnelServer = yes

编辑tinc-up

#!/bin/sh
/sbin/ifconfig tun10 up
/sbin/ifconfig tun10 inet 10.255.1.1/24
/etc/rc.d/pf reload

编辑hosts/server, 在顶部添加

Compression = 10
Subnet = 0.0.0.0/0

复制 client 端的 etc/tinc/hosts/client 到 etc/tinc/hosts/, 该步骤可以先配置客户端后再完成.

客户端

生成密钥

tinc init client

配置 etc/tinc/tinc.conf

Name = client
Interface = tun10
ConnectTo = server
MaxTimeout = 5

配置 etc/tinc/hosts/client, 头部添加

Compression = 10
Subnet = 10.255.1.1

复制 server 端的 etc/tinc/hosts/server 到 etc/tinc/hosts/, 修改头部

Address = server_域名或者ip地址
Compression = 10
-----BEGIN RSA PUBLIC KEY-----
.....

NAT

pf.conf

scrub all no-df random-id fragment reassemble
nat on $ext_if from { 10.255.1/24 } to any -> ($ext_if)

启动

附件为FreeBSD rc.d 脚本, 用于启动 tincd

调试可采用 tincd -D -d3 或 tincd -D -d4

FreeBSD tincd rc.d 启动脚本

freebsd/tinc.txt · 最后更改: 2021/08/18 11:13 由 Hshh