ubuntu配置openvpn

在EC2的ubuntu上配置openvpn还是比较简单的,主要是参考了这篇文章
简单的说就是aptitude install openvpn lzop
然后在/usr/share/doc/openvpn/examples/easy-rsa/2.0里面依次运行
source vars
./clean-all
./build-ca 自签CA
./build-key-server server 签发服务器证书
./build-key client 签发客户端证书
./build-dh 生成Diffie Hellman参数
运行以上命令后会在key目录下生成服务端证书,客户端证书
之后就是配置OpenVPN

[text]

port 50000 #端口50000
proto udp #使用udp
dev tun #使用tun
ca key/ca.crt #根证书
cert key/server.crt #证书
key key/server.key # This file should be kept secret
dh key/dh1024.pem
server 10.10.0.0 255.255.255.0 #ip段
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4" #推送的dns
keepalive 10 30
comp-lzo #开启压缩
max-clients 60 #最多60个客户端
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3
mute 20
[/text]
iptables里开启转发
[bash]
iptables -t nat -A POSTROUTING -s 10.168.0.0/16 -o eth0 -j MASQUERADE
内核参数添加
net.ipv4.ip_forward = 1
[/bash]
然后启动openvpn就行了。

windows和linux下的客户端配置基本都是一样的,以前在学校使用openvpn也是用相同的配置文件的 。
[text]
client
dev tun
proto udp
remote xxxx.xxx.xxx 50000
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client.crt
key client.key
ns-cert-type server
comp-lzo
verb 3
mute 20
keepalive 20 60
redirect-gateway #一定注意这个,这个是修改默认路由策略。

[/text]

此条目发表在Admin, System分类目录。将固定链接加入收藏夹。

发表回复