linode XEN VPS (Linux)
首先,你要确保自己的vps已经按照Getting Started With Linode这篇文章做好了初步的准备工作。对安装VPN而言,
需要注意的就是设置好更新源。编辑你的/etc/apt/sources.list文件,去掉"##universe
repositories"之后所有行的注释,让文件变成和下面的一样。当然,这一步需要用sudo或者在root下来完成,后面所有的命令都是如此。
## main & restricted repositories
deb http://us.archive.ubuntu.com/ubuntu/ karmic main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic main restricted
deb http://security.ubuntu.com/ubuntu karmic-security main restricted
deb-src http://security.ubuntu.com/ubuntu karmic-security main restricted
## universe repositories
deb http://us.archive.ubuntu.com/ubuntu/ karmic universe
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic universe
deb http://us.archive.ubuntu.com/ubuntu/ karmic-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic-updates universe
deb http://security.ubuntu.com/ubuntu karmic-security universe
deb-src http://security.ubuntu.com/ubuntu karmic-security universe
接着用下面的命令更新你的软件包数据库
apt-get update
现在我们可以正式安装VPN server了。这里我们选择pptp(vpn 协议的一种),因为简单,一条命令搞定。剩下的无非是一些配置。
apt-get install pptpd
pptpd安装完成后,编辑/etc/pptpd.conf文件,去掉下面两行的注释或者直接添加这两行(在文件的最后).这一步是配置ip地址的
范围。
localip 192.168.0.1
remoteip 192.168.0.234-238,192.168.0.245
然后在/etc/ppp/chap-secrets文件中添加vpn用户,按照下面的格式,每个用户一行。
username pptpd password *
为了让你的用户连上VPN后能够正常地解析域名,我们需要手动设置DNS.
编辑/etc/ppp/options,找到ms-dns这一项,设置你的DNS.这里我推荐的是Google 最近发布的Public
DNS
,原因是因为好记。
ms-dns 8.8.8.8
ms-dns 8.8.4.4
编辑/etc/sysctl.conf文件,找到"net.ipv4.ip_forward=1"这一行,去掉前面的注释。
net.ipv4.ip_forward=1
运行下面的命令让配置生效。
sysctl -p
重启pptpd服务
/etc/init.d/pptpd restart
Issue the following commands to configure iptables
to properly
forward traffic through the VPN:
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT
iptables -A FORWARD -j REJECT
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
Before continuing, insert these iptables
rules into your system's
/etc/rc.local
file to ensure that theses iptables
rules will
be recreated following your next reboot cycle:
File excerpt:
/etc/rc.local
#!/bin/sh -e
#
# [...]
#
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT
iptables -A FORWARD -j REJECT
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
exit 0
ok,安装完毕。赶快用上你的VPN吧。
参考文章:
http://blog.cuoluo.net/2009/12/install-pptp-vpn-in-linode-vps/
http://library.linode.com/networking/openvpn-ubuntu-9.10-karmic#installing_openvpn
页:
[1]