系統環境:本次系統採用 系統爲基礎。html
[root@gjp~]# cat /etc/redhat-release linux
CentOS release 6.4 (Final)c++
所需工具:dkms-2.0.17.5-1.noarch.rpmapp
kernel_ppp_mppe-1.0.2-3dkms.noarch.rpmtcp
pptpd-1.3.4-2.rhel6.i386.rpmide
ppp-2.4.5-17.0.rhel6.narch.rpm工具
首先先把以上工具下載到/home/download下:spa
#mkdir -p /home/download.net
#cd /home/download3d
#wget http://www.hi-vps.com/downloads/dkms-2.0.17.5-1.noarch.rpm
#wget http://wty.name/linux/sources/kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
#http://poptop.sourceforge.net/yum/stable/rhel6/i386/ppp-2.4.5-33.0.rhel6.i686.rpm
#http://poptop.sourceforge.net/yum/stable/rhel6/i386/pptpd-1.4.0-1.el6.i686.rpm
繼續安裝庫:
#yum -y install make libpcap iptables gcc-c++ logrotate tar cpio perl pam tcp_wrappers
安裝剛纔下的工具:
#rpm -ivh dkms-2.0.17.5-1.noarch.rpm
#rpm -ivh kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
#rpm -Uvh ppp-2.4.5-33.0.rhel6.i686.rpm
#rpm -ivh pptpd-1.4.0-1.el6.i686.rpm
把裏面的IP跟DNS改爲你所使用的DNS。。。
mknod /dev/ppp c 108 0
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 「mknod /dev/ppp c 108 0″ >> /etc/rc.local
echo 「echo 1 > /proc/sys/net/ipv4/ip_forward」 >> /etc/rc.local
echo localip 172.16.36.1 >> /etc/pptpd.conf
echo remoteip 172.16.36.2-254 >> /etc/pptpd.conf
echo ms-dns 222.85.85.85 >> /etc/ppp/options.pptpd
echo ms-dns 222.88.88.88 >> /etc/ppp/options.pptpd
防火牆配置:
iptables -t nat -A POSTROUTING -s 172.16.36.0/24 -j SNAT –to-source `ifconfig | grep ‘inet addr:’| grep -v ’127.0.0.1′ | cut -d: -f2 | awk ‘NR==1 { print $1}’`
在此命令是用反掩號括起來的
[root@gjp ~]# ifconfig |grep 'inet addr' |grep -v '127.0.0.1' |cut -d: -f2 |awk 'NR==1 { print $1}'
10.0.3.251 (獲取本機在使用的ip)
iptables -A FORWARD -p tcp –syn -s 172.16.36.0/24 -j TCPMSS –set-mss 1356
服務啓動:
service iptables save
chkconfig iptables on
chkconfig pptpd on
service iptables start
service pptpd start
好的,到這裏,×××就已經搭建完成了。。。
下面開始創建用戶:
#vi /etc/ppp/chap-secrets
編輯內容爲(IP中*號表明全部):
# Secrets for authentication using CHAP
# client server secret IP addresses
用戶名 pptpd 密碼 *
gjp * 12345 *
配置好之後,重啓pptp服務
#service pptpd start
後續查看理解:
ppp0 Link encap:Point-to-Point Protocol
inet addr:172.16.36.1 P-t-P:172.16.36.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1396 Metric:1
RX packets:1641 errors:0 dropped:0 overruns:0 frame:0
TX packets:1502 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:327280 (319.6 KiB) TX bytes:370597 (361.9 KiB)