用 Softether 打穿 NAT
May 22, 2016
NAT,网络地址转换.在我发现我的 IP 变成 10.127.x.x 之后,事情就很明朗了,我在 NAT 后面了.
CMCC 也是很放肆啊,动不动就把人丢到 NAT 后面.
这里我们采用一个非常简单而又粗暴的方式来打穿 NAT,Softether.
首先你要有一个暴露在外网的服务器.然后我们编译安装源码.
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf && sysctl --system
wget http://www.softether-download.com/files/softether/v4.21-9613-beta-2016.04.24-tree/Linux/SoftEther_VPN_Server/64bit_-_Intel_x64_or_AMD64/softether-vpnserver-v4.21-9613-beta-2016.04.24-linux-x64-64bit.tar.gz
tar xf softether-vpnserver-v4.21-9613-beta-2016.04.24-linux-x64-64bit.tar.gz
cd vpnserver
make
然后他会问你几个问题.
Do you want to read the License Agreement for this software ?
1
Did you read and understand the License Agreement ?
1
Did you agree the License Agreement ?
1
PS:一定要读哦.
然后我们就可以把它挪到一个我们认为可以的地方.比如 /usr/local
cd ..
mv vpnserver /usr/local
cd /usr/local/vpnserver/
同时加上权限,别都加 777
chmod 600 *
chmod 700 vpnserver
chmod 700 vpncmd
接下来需要更改密码并创建一个 NAT —别担心,这个 NAT 是我们的.
./vpnserver start
./vpncmd
1 #Management of VPN Server or VPN Bridge
#Enter 两次.若更改了端口则在地址处输入 localhost:5555
ServerPasswordSet
#输入密码.
如果你的 443 被占用了的话,在这一步可能会出错,在 vpn_server.config 中将 443 改为 5555 并连接即可.
HubCreate VPN
Hub VPN
SecureNatEnable
接下来我们创建用户.
UserCreate baka
UserPasswordSet baka
打开 L2TP.
IPsecEnable
然后我们需要一个证书,Let’s Encrypt 的证书都有吧.
ServerCertGet ~/cert.cer
SstpEnable yes #打开 SSTP
OK,这样就可以了.连上 Softether,接下来就直接用 iptables 来 forward 到机子上就可以了.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.