Build an automated shell script using Ubuntupptpd

Source: Internet
Author: User
Tags get ip

Build an automated shell script using Ubuntupptpd

#!/bin/bash## pptp.sh is writed by Mislost.## Auto install and config pptpd vpn server## Update system and install pptpsudo apt-get -y updatesudo apt-get -y install ppp pptpd## get ip and remoteipPRIVATE_IP=`ifconfig eth0 | grep "inet addr:" | sed -n 's/.*inet addr:\(.*\)  B.*/\1/p'`
SUBNET=`echo ${PRIVATE_IP%.*}.10-250`## config /etc/pptpd.confsudo sed -i "s/^localip .*/localip $IP/;s/^remoteip.*/remoteip $SUBNET/" /etc/pptpd.conf## config /etc/ppp/optionssudo sed -i 's/^ms-dns.*/ms-dns 8.8.8.8/' /etc/ppp/options## create vpn accountsudo sh -c 'echo "test     pptpd   test      *" >> /etc/ppp/chap-secrets'## config ip_forwardsudo sed -i 's/^\(net.ipv4.ip_forward=\).*/\1=1/' /etc/sysctl.confsudo sysctl -p## iptables forwardsudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADEecho "sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE" >> /etc/rc.localsudo iptables -A FORWARD -p tcp --syn -s ${PRIVATE_IP%.*}.0/24 -j TCPMSS --set-mss 1356echo "sudo iptables -A FORWARD -p tcp --syn -s ${PRIVATE_IP%.*}.0/24 -j TCPMSS --set-mss 1356" >> /etc/rc.local## restart pptpd servicesudo killall pptpdsudo service pptpd restart##echo "Successful~!"


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.