CentOS7 one-click VPN script

Source: Internet
Author: User

CentOS7 one-click VPN script
Install the PPTP script ------------------------------------------------------------------#! /Bin/bashYum-y updateWget-c http://dl.fedoraproject.org/pub/epel/7/x86_64/p/pptpd-1.4.0-2.el7.x86_64.rpmyum-y install pptpd-1.4.0-2.el7.x86_64.rpmCp-rf/etc/pptpd. conf/etc/pptpd. conf. bakcat>/etc/pptpd. conf <EOFlocalip 192.168.144.1remoteip 192.168.144.2-254EOFCp-rf/etc/ppp/options.ppt pd. bakcat>/etc/ppp/options.ppt pd <EOFms-dns 8.8.8.8ms-dns 8.8.4.4EOFYum-y install pppCp-rf/etc/ppp/chap-secrets/etc/ppp/chap-secrets.bakcat>/etc/ppp/chap-secrets <EOFvpn pptpd 123456 * EOFCp-rf/etc/rc. d/rc. local/etc/rc. d/rc. local. bakcat>/etc/rc. d/rc. local <EOFiptables-a input-p gre-j ACCEPTiptables-t nat-a postrouting-s 192.168.144.0/24-j MASQUERADEiptables-a input-p tcp-m multiport -- dport 1723- j ACCEPTecho 1>/proc/sys/net/ipv4/ip_forwardsystemctl restart pptpdEOFChmod + x/etc/rc. d/rc. localIptables-a input-p gre-j ACCEPTiptables-t nat-a postrouting-s 192.168.144.0/24-j MASQUERADEiptables-a input-p tcp -- dport 1723-j ACCEPTecho 1>/proc /sys/net/ipv4/ip_forwardsystemctl restart pptpdsystemctl enable pptpdEcho "++ ++ "echo" Success! And the VPN account is: "echo" Method: PPTP "echo" User: vpn "echo" Password: 123456 "echo" If you want modify, with vim tool at/etc/ppp/chap-secrets "echo" Good luck! "------------------------------------------------------------- Install the L2tp script ----------------------------------------------------------#! /Bin/bashYum-y updateyum-y install openswan net-toolsMv/etc/ipsec. conf/etc/ipsec. conf. bakcat>/etc/ipsec. conf <EOFconfig setupprotostack = netkeydumpdir =/var/run/pluto/nat_traversal = yesVirtual_private = % v4: 10.0.0.0/8, % v4: 192.168.0.0/16, % v4: 172.16.0.0/12, % v4: 25.0.0.0/8, % v4: 100.64.0.0/10, % v6: fd00:/8, % v6: fe80:/10Conn L2TP-PSK-NATRightsubnet = vhost: % privAlso = L2TP-PSK-noNATConn L2TP-PSK-noNATAuthby = secretPfs = noAuto = addKeyingtries = 3Rekey = noIkelifetime = 8 hKeylife = 1 hType = transportLeft = YOUR_IPADDRLeftprotoport = 17/1701Right = % anyRightprotoport = 17/% anyEOFMv/etc/ipsec. secrets/etc/ipsec. secrets. bakcat>/etc/ipsec. secrets <EOFinclude/etc/ipsec. d/*. secretsYOUR_IPADDR% Any:PSK www.so-love.com EOFEcho "++" echo "Shell Test that your ip is: "echo $ (ifconfig | awk-F' [] + |:''/inet/{if ($3! ~ /^ 192.168 | ^ 172.16 | ^ 10 | ^ 127 | ^ 0/& $3 ~ /. {1, 3 }\.. {1, 3 }\.. {1, 3 }\.. {1, 3}/) print $3} ') sed-I "s/YOUR_IPADDR/$ (ifconfig | awk-F' [] + |: ''/inet/{if ($3! ~ /^ 192.168 | ^ 172.16 | ^ 10 | ^ 127 | ^ 0/& $3 ~ /. {1, 3 }\.. {1, 3 }\.. {1, 3 }\.. {1, 3}/) print $3} ')/g "/etc/ipsec. confsed-I "s/YOUR_IPADDR/$ (ifconfig | awk-F' [] + |:''/inet/{if ($3! ~ /^ 192.168 | ^ 172.16 | ^ 10 | ^ 127 | ^ 0/& $3 ~ /. {1, 3 }\.. {1, 3 }\.. {1, 3 }\.. {1, 3}/) print $3} ')/g "/etc/ipsec. secretsecho "++"Echo 1>/proc/sys/net/ipv4/ip_forwardfor each in/proc/sys/net/ipv4/conf/* doEcho 0> $ each/accept_redirectsEcho 0> $ each/send_redirectsdone# Cp-rf/etc/sysctl. conf/etc/sysctl. conf. bak # echo 'Net. ipv4.ip _ forward = 1'>/etc/sysctl. conf # sysctl-pSystemctl restart ipsec. serviceipsec verify# Tail-f/var/log/secureWget-c http://dl.fedoraproject.org/pub/epel/testing/7/x86_64/x/xl2tpd-1.3.6-7.el7.x86_64.rpmyum install-y xl2tpd-1.3.6-7.el7.x86_64.rpmMv/etc/xl2tpd/xl2tpd. conf/etc/xl2tpd/xl2tpd. conf. bakcat>/etc/xl2tpd/xl2tpd. conf <EOF [global][Lns default] ip range = 192.168.1.128-192.168.1.254local ip = 192.168.1.99require chap = yesrefuse pap = yesrequire authentication = yesname = LinuxVPNserverppp debug =/etc/ppp/options. xl2tpdlength bit = yesEOFYum-y install pppmv/etc/ppp/options. xl2tpd/etc/ppp/options. xl2tpd. bakcat>/etc/ppp/options. xl2tpd <EOFipcp-accept-localipcp-accept-remotems-dns8.8.8.8ms-dns8.8.4.4noccpauthcrtsctsidle 1800mtu 1410mru 1410nodefaultroutedebuglockproxyarpconnect-delay 5000EOFMv/etc/ppp/chap-secrets/etc/ppp/chap-secrets.bakcat>/etc/ppp/chap-secrets <EOF # Secrets for authentusing CHAP # clientServerSecretIP addressesvpn l2tpd 123456 * EOFCat>/etc/rc. d/rc. local <EOFiptables-t nat-a postrouting-s 192.168.1.0/24-j MASQUERADEecho 1>/proc/sys/net/ipv4/ip_forwardfor each in/proc/sys/net/ipv4 /conf/* doEcho 0> $ each/accept_redirectsEcho 0> $ each/send_redirectsdonesystemctl restart ipsec. serviceps-ef | grep 'xl2tpd '|/usr/sbin/xl2tpdEOFChmod + x/etc/rc. d/rc. localIptables-t nat-a postrouting-s 192.168.1.0/24-j MASQUERADE/usr/sbin/xl2tpdEcho "++ ++ "echo" Success! And the VPN account is: "echo" Method: L2TP "echo" User: vpn "echo" Password: 123456 "echo" PSK: www.so-love.com "echo" If you want modify, with vim tool at/etc/ppp/chap-secrets "echo" Good luck! "

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.