ubuntu server 14.04 配置pptp
时间:2016-05-30 15:42 来源:linux.it.net.cn 作者:IT
1.安装pptpd服务软件
sudo apt-get install pptpd
2.需要修改的有三个文件
/etc/pptp.conf
/etc/ppp/pptp-options
/etc/ppp/chap-secrets
a). 修改/etc/pptp.conf 文件
在尾部添加
localip 192.168.2.152 (服务器公网ip)
remoteip 10.2.1.1-10 (分给客户端连接的ip)
b).修改/etc/ppp/pptp-options
在文件底部添加dns信息
ms-dns 8.8.8.8
ms-dns 8.8.4.4
c).修改pptp用户文件 /etc/ppp/chap-secrets
添加格式如下
用户 服务 密码 限制ip
vpn01 pptpd vpn01 *
3.修改系统文件/etc/sysctl.conf
开启ipv4 转发功能
net.ipv4.ip_forward=1
执行# sysctl -p 使系统生效
4.设置iptables nat 映射
//此步若不设置 vpn连接后无法上外网。
iptables –t nat –A POSTROUTING –s 10.2.1.0/24 –o eth0 –j MASQUERADE
iptables-save > /etc/iptables-rules //讲规则保存到iptables-rules这个文件中
5.修改/etc/network/interfaces 开机读取网卡文件时同时加载iptables-rules文件
在最后添加以下内容
pre-up iptables-restore < /etc/iptables-rules
配置后有时候会出现有些网站能打开有些网站打不开。解决方法
iptables -A FORWARD -s 10.2.1.0/24 -p tcp -m tcp –tcp-flags SYN,RST SYN -j TCPMSS –set-mss 1200
设置一下mtu包的大小为1200 然后测试OK
(责任编辑:IT)
1.安装pptpd服务软件 sudo apt-get install pptpd 2.需要修改的有三个文件 /etc/pptp.conf /etc/ppp/pptp-options /etc/ppp/chap-secrets a). 修改/etc/pptp.conf 文件 在尾部添加 localip 192.168.2.152 (服务器公网ip) remoteip 10.2.1.1-10 (分给客户端连接的ip) b).修改/etc/ppp/pptp-options 在文件底部添加dns信息 ms-dns 8.8.8.8 ms-dns 8.8.4.4 c).修改pptp用户文件 /etc/ppp/chap-secrets 添加格式如下 用户 服务 密码 限制ip vpn01 pptpd vpn01 * 3.修改系统文件/etc/sysctl.conf 开启ipv4 转发功能 net.ipv4.ip_forward=1 执行# sysctl -p 使系统生效 4.设置iptables nat 映射 //此步若不设置 vpn连接后无法上外网。 iptables –t nat –A POSTROUTING –s 10.2.1.0/24 –o eth0 –j MASQUERADE iptables-save > /etc/iptables-rules //讲规则保存到iptables-rules这个文件中 5.修改/etc/network/interfaces 开机读取网卡文件时同时加载iptables-rules文件 在最后添加以下内容 pre-up iptables-restore < /etc/iptables-rules 配置后有时候会出现有些网站能打开有些网站打不开。解决方法 iptables -A FORWARD -s 10.2.1.0/24 -p tcp -m tcp –tcp-flags SYN,RST SYN -j TCPMSS –set-mss 1200
设置一下mtu包的大小为1200 然后测试OK |