32

Ubuntu install and configuration PPTP service

 5 years ago
source link: https://www.linuxprobe.com/ubuntu-pptp.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
安装PPTP,以用来提供VPN服务
sudo apt-get install pptpd
配置pptp
sudo vi /etc/pptpd.conf

取消掉以下两行的注释:

localip 192.168.0.1 #客户端连接后的网关

remoteip 192.168.0.234-238 #客户端可用IP池

分配账号
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账户连接

修改DNS
sudo vi /etc/ppp/pptpd-options

找到ms-dns,取消注释,改成相应的DNS

ms-dns 8.8.8.8
ms-dns 8.8.4.4
开启内核IP转发
sudo vi /etc/sysctl.conf

取消掉 net.ipv4.ip_forward=1 的注释.

保存后执行

sudo sysctl -p
开启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 

#当eth0网卡加载时自动载入导出好的规则 192.168.0.0/24是你在上面设置的IP段,参考1 注意:文中的eth0代表的是你连接外网的那块网卡,如果是eth1就把上面的eth0改成eth1,如果不知道是哪块网卡连的外网的话,用ifconfig一下就知道了。

重启服务,让配置生效
sudo service pptpd restart
可以在rc.local中加入pptp启动命令,让pptp服务自启
sudo vim /etc/rc.local
service pptpd start 

#在exit的上面加入这句


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK