Ubuntu pptpd 搭建自动化shell脚本

</pre><pre name="code" class="html">#!/bin/bash
## pptp.sh is writed by Misost.
## Auto install and config pptpd vpn server

## Update system and install pptp
sudo apt-get -y update
sudo apt-get -y install ppp pptpd

## get ip and remoteip
PRIVATE_IP=ifconfig eth0 | grep "inet addr:" | sed -n 's/.*inet addr:\(.*\)  B.*/\1/p'
SUBNET=echo ${PRIVATE_IP%.*}.10-250

## config /etc/pptpd.conf
sudo sed -i "s/^localip .*/localip $IP/;s/^remoteip.*/remoteip $SUBNET/" /etc/pptpd.conf

## config /etc/ppp/options
sudo sed -i 's/^ms-dns.*/ms-dns 8.8.8.8/' /etc/ppp/options

## create vpn account
sudo sh -c 'echo "test     pptpd   test      *" >> /etc/ppp/chap-secrets'

## config ip_forward
sudo sed -i 's/^\(net.ipv4.ip_forward=\).*/\1=1/' /etc/sysctl.conf
sudo sysctl -p

## iptables forward
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE" >> /etc/rc.local

sudo iptables -A FORWARD -p tcp --syn -s ${PRIVATE_IP%.*}.0/24 -j TCPMSS --set-mss 1356
echo "sudo iptables -A FORWARD -p tcp --syn -s ${PRIVATE_IP%.*}.0/24 -j TCPMSS --set-mss 1356
" >> /etc/rc.local

## restart pptpd service
sudo killall pptpd
sudo service pptpd restart

##
echo "Successful~!"


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。