Home > 电脑网络|network > DD-WRT上openvpn客户端的设置

DD-WRT上openvpn客户端的设置

November 22nd, 2014 Leave a comment Go to comments

openvpn-logo主要根据这篇文章进行设置,命令行操作,简单快速,但是这篇文章没有加入dh文件,所以稍作修改。最后firewall设置中的IP也应该根据自己的服务器设置。

进入DD-WRT界面,点击administration->commands,将以下代码贴进代码框,修改红色部分,替换成自己的服务器IP和端口。用文本编辑器(如emeditor等)打开相应的证书和key,贴入到代码框对应位置。点击save startup。

[ -d /tmp/openvpnsrv ] || mkdir /tmp/openvpnsrv
echo "
client
dev tun
proto udp
remote YOUR SERVER IP 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca /tmp/openvpnsrv/ca.crt
cert /tmp/openvpnsrv/client.crt
key /tmp/openvpnsrv/client.key
dh /tmp/openvpnsrv/dh.pem
ns-cert-type server
cipher bf-cbc
comp-lzo
verb 3
mute 20" > /tmp/myvpnsrv.conf
echo "
-----BEGIN CERTIFICATE-----
PASTE-YOUR-CA HERE
-----END CERTIFICATE-----
" > /tmp/openvpnsrv/ca.crt
echo "
-----BEGIN PRIVATE KEY-----
PASTE-YOUR-CLIENT KEY HERE
-----END PRIVATE KEY-----
" > /tmp/openvpnsrv/client.key
echo "
-----BEGIN CERTIFICATE-----
PASTE-YOUR-CERTIFICATE HERE
-----END CERTIFICATE-----
" > /tmp/openvpnsrv/client.crt
echo "
-----BEGIN DH PARAMETERS-----
PASTE-YOUR-DH HERE
-----END DH PARAMETERS-----
" > /tmp/openvpnsrv/dh.pem
ln -s /usr/sbin/openvpn /tmp/myvpn
sleep 10
chmod 400 /tmp/openvpnsrv/*
/tmp/myvpn --config /tmp/myvpnsrv.conf --daemon
sleep 15

在代码框中输入以下命令,IP段根据自己的服务器设置,前2位即可

iptables -A POSTROUTING -t nat -o tun0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE

重启路由器

  1. No comments yet.
  1. No trackbacks yet.