PPTPD源码安装 Install PPTPD from source code

今天花了一晚上倒腾VPN服务器,因为是用的CENTOS,没法直接apt-get install pptpd,虽然网上有RPM包,但最后还是选择了源码安装,过程中碰到很多问题,在此总结一下:

1. make install后默认没有安装服务,需要自行创建/etc/rc.d/init.d/pptpd,写入代码如下:

#!/bin/sh
#
# Startup script for pptpd
#
# chkconfig: 345 85 15
# description: PPTP server
# processname: pptpd
# config: /etc/pptpd.conf

# Source function library.
. /etc/rc.d/init.d/functions
# See how we were called.
case "$1" in
start)
echo -n "Starting pptpd: "
if [ -f /var/lock/subsys/pptpd ] ; then
echo
exit 1
fi

daemon /usr/local/sbin/pptpd
echo
touch /var/lock/subsys/pptpd
;;
stop)
echo -n "Shutting down pptpd: "
killproc pptpd
echo
rm -f /var/lock/subsys/pptpd
;;
status)
status pptpd
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac

exit 0

2. 将pptpd安装为服务并随机启动:

chkconfig --add pptpd
chkconfig pptpd on
service pptpd start

3. 客户端链接的时候很可能提示错误,这是因为通过yum install ppp安装的组件版本与pptpd所支持的版本不一致,解决办法,修改/etc/pptpd.options,注释掉logwtmp即可。这个问题折磨我好久!=-=!

4. 还有一个很折腾人的问题,就是连上VPN后无法访问外网只能访问VPN服务器,原因是要通过iptables转发数据包才行,代码如下:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
//add it to /etc/rc.d/rc.local for auto execution when rebooted.

5. 附上具体安装步骤:

//install ppp 
yum install ppp

//install pptpd, download source code and
./configure
make
make install

// update pptpd configurations in file /etc/pptpd.conf:
localip     192.168.9.1
remoteip    192.168.9.11-30

// /etc/ppp/options.pptpd:
ms-dns    8.8.8.8
ms-dns    8.8.4.4

// /etc/ppp/chap-secrets. Each line in the file has the format:
<username> pptpd <passwd> *

// /etc/sysctl.conf, use the following config:
net.ipv4.ip_forward = 1

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *