#!/bin/bash
#function ================pptpd auto install scripts=======================
#author Woo
#version 1.0
#date 2012-11-09
green='\e[0;32m'
red='\e[0;31m'
blue='\e[0;36m'
blue1='\e[5;31m'
NC='\e[0m'
path_soft=$(pwd)
function base {
for i in $(rpm -q gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-de
vel openssl openssl-devel bison bison-devel readline readline-devel libmcrypt libmcrypt-devel net-snmp-devel gcc gcc-c++ apr apr-util postgresql-
libs openssl openssl-devel autoconf automake fiex* libxml* ncurses* libtool* libxslt libxslt-devel curl* bzip2* gd gd-devel freetype freetype-d
evel libpng*|grep 'not installed' | awk '{print $2}')
do
zypper -n install $i;
done
}
function pptpd {
zypper -n install pptpd
#start pptpd services
for name in pptpd
do
service ${name} restart
chkconfig --add ${name}
chkconfig --level 345 ${name} on
done
}
function config {
cp /etc/pptpd.conf /etc/pptpd.conf.back -rf
sed -i "s/localip\ 192.168.0.1/localip\ 1.1.1.1/g" /etc/pptpd.conf
sed -i "s/remoteip\ 192.168.1.100-199/remoteip\ 10.254.200.100-199/g" /etc/pptpd.conf
cp /etc/ppp/options.ppp0 /etc/ppp/options.ppp0.back -rf
cat > /etc/ppp/options.ppp0 << EOF
name suse-pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
proxyarp
lock
nobsdcomp
novj
novjccomp
nologfd
idle 2592000
ms-dns 61.139.2.69
ms-dns 8.8.8.8
EOF
cp /etc/ppp/chap-secrets /etc/ppp/chap-secrets.back
echo "mjjwu pptpd root *" >> /etc/ppp/chap-secrets
echo 1 > /proc/sys/net/ipv4/ip_forward
}
function restart {
service pptpd restart
}
function main {
base
pptpd
config
restart
}
main
将上述脚本保存为文件pptpd.sh
运行脚本前为pptpd.sh文件赋予运行权限
chmod +x pptpd.sh
运行脚本
./pptpd.sh
有些版本pptpd的chap-secrets文件格式与脚本有差异,需要将pptpd改为hostname,用*代替也可以
为服务器设置IP包转发权限
sudo vi /etc/sysctl.conf
net.ipv4.ip_forward=1
sudo systrl -p
安装iptables,并建立nat
sudo iptables -t nat -A POSTROUTING -s 10.254.200.0/24 -o eth0 -j MASQUERADE
启动pptpd服务
service pptpd start
查看服务状态
service pptpd status