Set up PPTP on the Ubuntu

PPTP(点对点隧道协议,Point-to-Point Tunnel Protocol)是最基本的VPN协议。它的配置相当简单,但稳定性一般。1

  1. 安装PPTPD服务(Point-to-Point Tunnel Protocol Daemon)
# apt-get install pptpd
  1. 编辑内网IP设置 /etc/pptpd.conf

文件末尾加入以下内容:

localip 10.0.0.1
remoteip 10.0.0.100-200

以 10.0.0.1 作为内网网关,10.0.0.100 到 200 作为服务器分配给每个连接的内网IP。

  1. 在 /etc/ppp/chap-secrets 中加入用户名和密码

在表头下面另起一行,按照以下格式来添加用户名和密码。多个用户名用空行来分隔。

username pptpd password *

第四个*号表示自动分配IP地址。每个字段中间用空格隔开。

  1. 在 /etc/ppp/pptpd-options 中加入 Google 提供的公共DNS配置

将最后两行代表注释的 # 号去掉,然后修改地址为公共DNS,最后需要达成的内容:

ms-dns 8.8.8.8
ms-dns 8.8.4.4
  1. 设置 ipv4forwarding 转发和 NAT 规则。首先编辑 /etc/sysctl.conf 如下

net.ipv4.ip_forward = 1 之前的注释#号去掉

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

输入以下命令使刚刚的配置更改生效;确保配置更新的时候看到确认 ip_forwarding 规则的提示:

# sysctl -p
  1. 在iptables中创立 NAT 规则。
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE && iptables-save
  1. 重启PPTPD服务,使得上述的更改生效
# service pptpd restart

Footnotes:

Author: Shi Shougang

Created: 2017-01-26 Thu 19:53

Emacs 24.3.1 (Org mode 8.2.10)

Validate