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