没办法,网络环境太烂,只能装个openvpn client连接到服务器,系统是mac,要求一直保持连接,还要能重启自动连。
安装过程如下:
1.安装openvpn
1brew install openvpn
2.安装tun/tap驱动
1wget http://downloads.sourceforge.net/tuntaposx/tuntap_20150118.tar.gz
2tar zxvf tuntap_20150118.tar.gz
3
4然后在mac os桌面下,双击tuntap_20150118.pkg安装
3.准备client.conf文件,这个文件就是标准的client端文件
4.测试是否可以正常启动
1/usr/local/opt/openvpn/sbin/openvpn --config /usr/local/etc/openvpn/ddky.conf
5.测试成功后在mac os编写plist文件
1vi /Library/LaunchDaemons/net.openvpn.plist
2<?xml version="1.0" encoding="UTF-8"?>
3<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
4"http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
5<plist version="1.0">
6
7<dict>
8 <key>Label</key>
9 <string>net.openvpn</string>
10 <key>KeepAlive</key>
11 <dict>
12 <key>NetworkState</key>
13 <true/>
14 </dict>
15 <key>Program</key>
16 <string>/usr/local/opt/openvpn/sbin/openvpn</string>
17 <key>ProgramArguments</key>
18 <array>
19 <string>openvpn</string>
20 <string>--config</string>
21 <string>/usr/local/etc/openvpn/client.conf</string>
22 </array>
23 <key>RunAtLoad</key>
24 <true/>
25 <key>TimeOut</key>
26 <integer>90</integer>
27 <key>WorkingDirectory</key>
28 <string>/usr/local/etc/openvpn</string>
29</dict>
30</plist>
6.然后运行
1sudo chown root:wheel /Library/LaunchDaemon/net.openvpn.plist
2
3sudo launchctl load /Library/LaunchDaemon/net.openvpn.plist
有用的命令:
1sudo launchctl load /Library/LaunchDaemon/net.openvpn.plist
2sudo launchctl unload /Library/LaunchDaemon/net.openvpn.plist
3sudo launchctl start /Library/LaunchDaemon/net.openvpn
4sudo launchctl stop /Library/LaunchDaemon/net.openvpn