第1章 搭建***服务器之pptp
1.1查看系统是否支持PPP
[root@caojiaoyue ~]# cat /var/ppp
cat: /var/ppp: No such file or directory
如果出现以上提示则说明ppp是开启的,可以正常架设pptp服务,若出现permission denied等提示,你需要先去vps面板里看看有没有enable ppp的 功能开关,如果没有则需要发个消息给你的提供商,让他们帮你开通,
1.2设置内核转发
sed -i's#net.ipv4.ip_forward = 0#net.ipv4.ip_forward = 1#g' /etc/sysctl.conf
grep forw/etc/sysctl.conf
sysctl -p
1.3安装pptp
需要安装epel源
wget -O /etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-6.repo
yum -y install pptpd
1.4 配置pptp
vim /etc/pptpd.conf
localip 10.0.0.9
remoteip 192.168.0.234-238
# 添she加本机公网IP(localip),分配×××用户的内网网段(remoteip)。
1.5设置用户与密码
vim /etc/ppp/chap-secrets
caojiaoyue * 123456 *
1.6 启动pptp
/etc/init.d/pptpd start
[root@caojiaoyue ~]# netstat -lntup|grep"ppt"
tcp 0 0 0.0.0.0:1723 0.0.0.0:* LISTEN 41269/pptpd
[root@caojiaoyue ~]#
注意默认端口是1723
1.7***日志配置
因为每次登陆和退出都会执行2个shell脚本
/etc/ppp/ip-up
/etc/ppp/ip-down
在这两个文件中加入日志命令
vim /etc/ppp/ip-up
#!/bin/bash
# This file should not be modified -- make localchanges to
# /etc/ppp/ip-up.local instead
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
LOGDEVICE=$6
REALDEVICE=$1
[ -f/etc/sysconfig/network-scripts/ifcfg-${LOGDEVICE} ] && /etc/sysconfig/network-scripts/ifup-post--realdevice ${REALDEVICE} ifcfg-${LOGDEVICE}
/etc/ppp/ip-up.ipv6to4 ${LOGDEVICE}
[ -x /etc/ppp/ip-up.local ] &&/etc/ppp/ip-up.local "$@"
echo"$PEERNAME 分配IP: $5 登录IP: $6 登录时间:`date -d today +%F_%T`" >> /var/log/pptpd.log
exit 0
[root@caojiaoyue ~]# vim /etc/ppp/ip-down
#!/bin/bash
# This file should not be modified -- make localchanges to
# /etc/ppp/ip-down.local instead
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
LOGDEVICE=$6
REALDEVICE=$1
/etc/ppp/ip-down.ipv6to4 ${LOGDEVICE}
[ -x /etc/ppp/ip-down.local ] &&/etc/ppp/ip-down.local "$@"
/etc/sysconfig/network-scripts/ifdown-post--realdevice ${REALDEVICE} \
ifcfg-${LOGDEVICE}
echo"$PEERNAME 下线IP: $6 下线时间: `date -d today +%F_%T`">> /var/log/pptpd.log
exit 0