如何部署 VPN 服务器构建公司私有网络
update @2018/05/21
update @2019/01/07
背景
公司在北京、上海、成都等地有多个办公区,办公区之间因为开发便利和业务往来需要建立安全的 vpn 隧道,经过调研,我们使用了优秀的开源 VPN 服务软件 SoftEtherVPN。
1. 安装 VPN Server 4.25
yum -y groupinstall "Development Tools" #yum -y install ncurses-devel openssl-devel readline-devel tar xf softether-vpnserver-v4.25-9656-rtm-2018.01.15-linux-x64-64bit.tar.gz chmod -R 755 vpnserver/ mv vpnserver/ /usr/local/ && cd /usr/local/vpnserver make ./vpnserver start netstat -ntlp
2. 添加开机启动脚本
cat >> /etc/init.d/vpnserver << EOF
#!/bin/sh
# chkconfig: 2345 99 01
# description: SoftEther VPN Server
DAEMON=/usr/local/vpnserver/vpnserver
LOCK=/var/lock/subsys/vpnserver
test -x $DAEMON || exit 0
case "$1" in
start)
$DAEMON start
touch $LOCK
;;
stop)
$DAEMON stop
rm $LOCK
;;
restart)
$DAEMON stop
sleep 3
$DAEMON start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
EOF
chmod 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 stop sed -i '/Disabled/ s/false/true /g' /usr/local/vpnserver/vpn_server.config service vpnserver start
相关推荐
BraveWangDev 2020-08-19
Wytheme 2020-06-11
RayDon 2015-05-20
书弋江山 2020-07-08
Vampor 2020-04-22
diediexiaomi 2020-04-21
huangzonggui 2020-04-17
Vampor 2020-04-17
xuezhengyyy 2020-02-15
huangzonggui 2020-01-30
thlm0 2019-12-31
furongwei 2019-12-23
OwenJi 2019-12-21
baixiaoshi 2019-12-01
wh0 2020-07-27
ThinkBigWinBig 2020-06-13
