2014年8月23日星期六

MAC_020:使用vpnc连接VPN

运行环境:MAC OS X 10.9.4

之所以使用vpnc而不使用MAC自带的VPN客户端,是发现自带的VPN客户端有时候不好使。

1. 安装vpnc,运行sudo port install vpnc

注意,需要事先安装MacPorts,安装步骤请参考《MAC下安装MacPorts》。
Password:
--->  Computing dependencies for vpnc
--->  Dependencies to be installed: tuntaposx
--->  Fetching archive for tuntaposx
--->  Attempting to fetch tuntaposx-20111101_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/tuntaposx
--->  Attempting to fetch tuntaposx-20111101_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/tuntaposx
--->  Installing tuntaposx @20111101_0
--->  Activating tuntaposx @20111101_0
--->  Cleaning tuntaposx
--->  Fetching archive for vpnc
--->  Attempting to fetch vpnc-0.5.3_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/vpnc
--->  Attempting to fetch vpnc-0.5.3_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/vpnc
--->  Installing vpnc @0.5.3_0
--->  Activating vpnc @0.5.3_0
--->  Cleaning vpnc
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.

2. 下载并安装TunTap
下载地址:http://tuntaposx.sourceforge.net/index.xhtml

3. 修改/opt/local/etc/vpnc/default.conf,修改后内容如下:
#IPSec gateway
#IPSec ID
#IPSec secret
#IKE Authmode hybrid
#Xauth username
#Xauth password

IPSec gateway 203.114.244.92
IKE Authmode psk
IPSec ID RH-standard
IPSec secret nodnerip
IKE DH Group dh2
NAT Traversal Mode natt
Xauth username pma


4. 启动/停止 vpnc
(1)启动:sudo vpnc
如果遇到如下错误:
MaPingdeMacBook-Pro:vpnc root# vpnc              
Enter password for pma@203.114.244.92:
Error binding to source port. Try '--local-port 0'
Failed to bind to 0.0.0.0:500: Address already in use
按照提示,使用sudo vpnc --local-port 0 启动vpnc,输出如下:
Enter password for pma@203.114.244.92:
Connect Banner:
| Unauthorized Access to this or any other Red Hat Inc. device
| is strictly prohibited. Violators will be prosecuted.
|

route: writing to routing socket: Can't assign requested address
add net 10.66.114.94: gateway 10.66.114.94: Can't assign requested address
add host 203.114.244.92: gateway 192.168.0.1
add net 172.16.0.0: gateway 10.66.114.94
add net 10.0.0.0: gateway 10.66.114.94
add net 10.66.127.17: gateway 10.66.114.94
add net 10.68.5.26: gateway 10.66.114.94
VPNC started in background (pid: 24992)...

(2)停止:sudo vpnc-disconnect,输出如下:
Terminating vpnc daemon (pid: 24894)       

参考文献:
1. http://vlinux.iteye.com/blog/593613
2. http://jingyan.baidu.com/article/48b37f8d4c44cb1a646488a1.html

没有评论: