Ubuntu 16.04 搭建PPTP服务器

共1016个字

步骤:

1.安装PPTP,以用来提供VPN服务.
sudo apt-get install pptpd

2.配置pptp.

sudo vi /etc/pptpd.conf
取消掉以下两行的注释:

localip 192.168.0.1 #客户端连接后的网关
remoteip 192.168.0.234-238 #客户端可用IP池

3.分配账号.

sudo vi /etc/ppp/chap-secrets
按如下格式添加账户,username用户名 pptp服务名 password密码 *代表允许任意IP连接

username pptpd “password” *

#例子 xiaobai pptpd “123456” * 这条表示允许任意客户端使用xiaobai账户进行连接
#例子 xiaobai1 pptpd “123456” 2.2.2.2 这条表示仅允许IP为2.2.2.2的客户端使用xiaobai1账户连接

4.修改DNS

sudo vi /etc/ppp/pptpd-options
找到ms-dns,取消注释,改成相应的DNS

ms-dns 8.8.8.8
ms-dns 8.8.4.4

5.开启内核IP转发

sudo vi /etc/sysctl.conf
取消掉 net.ipv4.ip_forward=1 的注释.

保存后执行

sudo sysctl -p

6.开启NAT转发,并保存配置文件至/etc/iptables-rules,重启后自动载入规则

sudo iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
sudo iptables-save > /etc/iptables-rules
sudo vim /etc/network/interfaces

#在eth0的最后一行加入
pre-up iptavles-restore < /etc/iptables-rules #当eth0网卡加载时自动载入导出好的规则 192.168.0.0/24是你在上面设置的IP段,参考1 注意:文中的eth0代表的是你连接外网的那块网卡,如果是eth1就把上面的eth0改成eth1,如果不知道是哪块网卡连的外网的话,用ifconfig一下就知道了。 7.重启服务,让配置生效 . sudo service pptpd restart 8.可以在rc.local中加入pptp启动命令,让pptp服务自启 sudo vim /etc/rc.local service pptpd start #在exit的上面加入这句

❤ 喜欢 72

3条回应:“Ubuntu 16.04 搭建PPTP服务器”

  1. Every weekend i used to pay a visit this website,
    because i want enjoyment, for the reason that this this site conations genuinely good funny data too.

  2. gamefly说道:

    I am sure this paragraph has touched all the internet people, its really really good post on building
    up new webpage.

  3. gamefly说道:

    I was wondering if you ever thought of changing the layout of your website?
    Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content
    so people could connect with it better. Youve got an awful lot of text for only having one or 2 images.

    Maybe you could space it out better?

发表评论

必填项已用*标注

归档于 Ubuntu