在macOS 10.12.4 Beta (16E183b)上测试通过。
安装相应软件
1 2 |
brew install tinc brew cask install tuntap |
(TAP驱动也可以在TunTap下载到。)
建立配置文件夹
1 |
mkdir -p /usr/local/etc/tinc/network_name/hosts |
建立Tinc配置
( tinc.conf 和 hosts/* 相关文件不再赘述,请参考Tinc配置文档。)
/usr/local/etc/tinc/network_name/tinc-up :
1 2 3 4 |
#!/bin/sh ifconfig $INTERFACE up ipconfig set $INTERFACE DHCP |
/usr/local/etc/tinc/network_name/tinc-down :
1 2 3 |
#!/bin/sh ifconfig $INTERFACE down |
设置脚本权限
1 |
chmod +x /usr/local/etc/tinc/network_name/tinc-{up,down} |
建立Launchd配置
以root权限向 /Library/LaunchDaemons/tincd.network_name.plist 写入:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>KeepAlive</key> <true/> <key>Label</key> <string>tinc.network_name</string> <key>ProgramArguments</key> <array> <string>/usr/local/sbin/tincd</string> <string>-n</string> <string>network_name</string> <string>-D</string> <string>--pidfile=/usr/local/var/run/tinc.network_name.pid</string> </array> <key>StandardErrorPath</key> <string>/tmp/tinc.network_name.err</string> <key>StandardOutPath</key> <string>/tmp/tinc.network_name.out</string> </dict> </plist> |
启动服务
1 |
sudo launchctl load tinc.network_name |
参考: