update @2018/05/21 update @2019/01/07背景公司在北京、上海、成都等地有多个办公区,办公区之间因为开发便利和业务往来需要建立安全的 vpn 隧道,经过调研,我们使用了优秀的开源 VPN 服务软件 SoftEtherVPN。1. 安装 VPN Server 4.25yum -y groupinstall “Development Tools”#yum -y install ncurses-devel openssl-devel readline-develtar xf softether-vpnserver-v4.25-9656-rtm-2018.01.15-linux-x64-64bit.tar.gzchmod -R 755 vpnserver/mv vpnserver/ /usr/local/ && cd /usr/local/vpnservermake./vpnserver startnetstat -ntlp2. 添加开机启动脚本cat >> /etc/init.d/vpnserver << EOF#!/bin/sh# chkconfig: 2345 99 01# description: SoftEther VPN ServerDAEMON=/usr/local/vpnserver/vpnserverLOCK=/var/lock/subsys/vpnservertest -x $DAEMON || exit 0case “$1” instart)$DAEMON starttouch $LOCK;;stop)$DAEMON stoprm $LOCK;;restart)$DAEMON stopsleep 3$DAEMON start;;*)echo “Usage: $0 {start|stop|restart}“exit 1esacexit 0EOFchmod 755 /etc/init.d/vpnserver/sbin/chkconfig –add vpnserver/etc/init.d/vpnserver stop/etc/init.d/vpnserver start3. 开启AD认证vim /usr/local/vpnserver/src/Cedar/Server.c以CN为关键字搜索,将ret = true;修改为ret = false;4. 端口映射及说明要在外网使用全功能的VPN服务器,需要映射如下端口:TCP:443 992 1194 5555 UDP:500 4500其中:tcp的443是softether client默认连接的端口,至少要保留这一个端口,或者修改为其它端口;tcp的1194是openvpn client的默认连接端口,可以修改客户端连接配置文件里的端口为443, 因此这个端口可以禁用;tcp的992是telnet的ssl端口, 如果443无法连接则可使用该端口,它是额外冗余端口,可以禁用;tcp的5555也是 softether 在443和992 之外冗余的端口,可以禁用;udp的500和4500是使用l2tp协议时需要用到的端口,主要是支持Android、IOS、Mac OSX连接服务器使用的;终上所述:当只需要在windows上使用 vpn client 客户端 或在 linux 上 使用 openvpn 连接时,只需要开启tcp的443即可,openvpn 的配置文件连接端口要修改为443; 防火墙只需要映射端口443(防火墙不区分tcp和udp)。当需需要手机、Mac连接时,需要额外开启500和4500。 防火墙需要映射端口443、500、4500(防火墙不区分tcp和udp)。4. 禁用动态DNS功能魔障一般的提示==This feature is not supported. It hasn’t been implemented yet on the open-source version of SoftEther VPN==这个提示是说"没有在开源版本的softether vpn上实现,并不是softetherVPN没有这个功能,而是它通过动态dns连到服务器进行判断,检测到是大陆的用户就会弹框提示:从VPN更新日志可以看到,因为国家安全问题,大陆政府要求VPN开发者必须遵从RPC的原则,希望大陆用户都使用 softether.cn 提供的商业产品,但它是付费使用,我们暂时没有相关经费,所以只能选择开源产品。https://www.softether.org/5-d…因此我们要停用动态 DNS 的功能,也就是说你想在家里搭建一个VPN服务器,那就不可能了,好在公司申请了公网ip,可以映射端口。service vpnserver stopsed -i ‘/Disabled/ s/false/true /g’ /usr/local/vpnserver/vpn_server.configservice vpnserver start https://www.softether.org/4-d