首页 > Internet > CentOS 操作系统架设 VPN 服务器图文教程

CentOS 操作系统架设 VPN 服务器图文教程

2011年8月17日 hypo 发表评论 阅读评论

很多国外优秀的服务都无法正常访问了,想要使用就得翻跟斗。而用的最多的应该就是代理和 VPN 了,现在免费的很不好使,限制特多很麻烦,有的还有广告,购买的 VPN 服务也是有速度和流量限制的,还不便宜。何不自己动手架设一台 VPN 服务器来使用呢?

自己架设 VPN 的成本非常低,比如购买 buyvm VPS,最便宜的15$/年,换成 RMB 才一百元不到,心动了吧?心动不如行动,下面是架设VPN的教程:

一、首先检查你VPS的PPP和TUN有没有启用:

cat /dev/ppp
cat /dev/net/tun

显示结果为:cat: /dev/ppp: No such device or address和cat: /dev/net/tun: File descriptor in bad state,表明通过,上述两条只要有一个没通过都不行。如果没有启用,你可以给VPS提供商Submit 一个 Ticket请求开通:

Hello

Could you enabled TUN-TAP for me? I want run pptp-vpn on my VPS.

Thank you.

确认 PPP 和 TUN 启用后,开始安装 ppp 和 iptables:

yum install -y ppp iptables

http://www.tofree.net/posts/236.html

二、安装pptp:

rpm -ivh http://acelnmp.googlecode.com/files/pptpd-1.3.4-1.rhel5.1.i386.rpm(适用32位系统)
rpm -ivh http://acelnmp.googlecode.com/files/pptpd-1.3.4-1.rhel5.1.x86_64.rpm(适用64位系统)

http://www.tofree.net/posts/236.html

三、配置pptp,编辑/etc/pptpd.conf文件:

vim /etc/pptpd.conf

http://www.tofree.net/posts/236.html

把下面字段前面的#去掉:

localip 192.168.0.1
remoteip 192.168.0.234-238,192.168.0.245

http://www.tofree.net/posts/236.html

四、编辑/etc/ppp/options.pptpd 文件:

vim /etc/ppp/options.pptpd

http://www.tofree.net/posts/236.html

去掉ms-dns前面的#,并使用Google的DNS服务器,修改成如下字段:

ms-dns 8.8.8.8
ms-dns 8.8.4.4

http://www.tofree.net/posts/236.html

五、设置VPN账号密码,编辑/etc/ppp/chap-secrets这个文件:

vim /etc/ppp/chap-secrets

http://www.tofree.net/posts/236.html

六、修改内核设置,使其支持转发,编辑 /etc/sysctl.conf 文件:

vim /etc/sysctl.conf

将“net.ipv4.ip_forward”的值改为1,同时在“net.ipv4.tcp_syncookies = 1”前面加#

http://www.tofree.net/posts/236.html

七、使 sysctl.conf 配置文件生效并添加 iptables 转发规则:

sysctl -p iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to-source ***.***.***.*** (***.***.***.***为你VPS的公网IP地址)

保存iptables转发规则:

/etc/init.d/iptables save

重启 iptables:

/etc/init.d/iptables restart

重启pptp服务:

/etc/init.d/pptpd restart

设置开机自动运行pptp服务:

chkconfig pptpd on

设置开机自动运行iptables服务:

chkconfig iptables on

http://www.tofree.net/posts/236.html

至此,Linux VPS架设VPN完成,如果连接出现错误619则输入如下命令解决:

rm /dev/ppp
mknod /dev/ppp c 108 0

如果出现错误734则修改/etc/ppp/options.pptpd文件,在require-mppe-128字段前面加#然后windows客户端连接按下图设置即可。

http://www.tofree.net/posts/236.html

转载敬请注明出处
本文链接地址:http://www.tofree.net/posts/236.html

分类: Internet 标签: 673 views