Skip to content

Instantly share code, notes, and snippets.

@huazhouji
Last active December 31, 2015 11:59
Show Gist options
  • Save huazhouji/7983312 to your computer and use it in GitHub Desktop.
Save huazhouji/7983312 to your computer and use it in GitHub Desktop.
vpn2
#!/bin/bash
clear
echo "========================================================================="
echo "AutoVPN v1.0.0 for Linux Written by badb0y "
echo "========================================================================="
echo "A tool to auto-compile & install PPTP VPN on Linux "
echo "For more information please visit http://code.google.com/p/autosetup"
echo ""
echo ""
echo "========================================================================="
if [ "$1" != "--help" ]; then
local_ip="172.16.36.1"
remote_ip="172.16.36.2-254"
tar -zxf ppp-2.4.4.tar.gz
cd ppp-2.4.4
cp -R pppd/plugins/radius/etc /usr/local/etc/radiusclient/
cd ..
tar -zxvf mysql-5.0.22.tar.gz
cd mysql-5.0.22
./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=all
make;make install
cd ..
groupadd mysql
useradd -g mysql mysql
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql/.
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig --level 345 mysql on
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
ldconfig
cp /usr/local/mysql/lib/mysql/libmysqlclient.so.15.0.0 /usr/local/mysql/lib/mysql/libmysqlclient_r.so
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
service mysql start
/usr/local/mysql/bin/mysqladmin -u root password root
service mysql restart
tar -zxvf freeradius-1.1.6.tar.gz
cd freeradius-1.1.6
./configure
make;make install
cp /usr/local/lib/libradius-1.1.6.so /usr/lib
cp /usr/local/lib/libeap-1.1.6.so /usr/lib
cd ..
cat >>/usr/local/etc/radiusclient/servers<<EOF
localhost vpn
EOF
mv /usr/local/etc/raddb/sql.conf /usr/local/etc/raddb/sql.conf.bak
mv /usr/local/etc/raddb/users /usr/local/etc/raddb/users.bak
mv /usr/local/etc/raddb/clients.conf /usr/local/etc/raddb/clients.conf.bak
mv /usr/local/etc/raddb/radiusd.conf /usr/local/etc/raddb/radiusd.conf.bak
cp config/sql.conf /usr/local/etc/raddb/sql.conf
cp config/users /usr/local/etc/raddb/users
cp config/clients.conf /usr/local/etc/raddb/clients.conf
cp config/radiusd.conf /usr/local/etc/raddb/radiusd.conf
cp config/vpn.sql /usr/local/etc/raddb/vpn.sql
cp config/grant.sql /usr/local/etc/raddb/grant.sql
cat >>/etc/ppp/options.pptpd<<EOF
debug
dump
plugin /usr/local/lib/pppd/2.4.4/radius.so
EOF
/usr/local/mysql/bin/mysql -uroot -proot < /usr/local/etc/raddb/vpn.sql
/usr/local/mysql/bin/mysql -uroot -proot < /usr/local/etc/raddb/grant.sql
service mysql restart
echo 1 >/proc/sys/net/ipv4/ip_forward
sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf
#长期用请启用下面几行,自己做相应设置
#echo "net.ipv4.ip_forward = 1" >>/etc/sysctl.conf
#iptables -t nat -F
#iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -j SNAT --to 999.999.999.999
#192.168.100.0/24为客户机IP段,999.999.999.999为本机IP
service pptpd restart
cp -R /usr/local/etc/radiusclient /etc/radiusclient/
echo "service pptpd stop" >/root/stop.sh
echo "service mysql stop" >>/root/stop.sh
echo "service pptpd start" >/root/start.sh
echo "service mysql start" >>/root/start.sh
echo "/usr/local/sbin/radiusd -X &" >>/root/start.sh
chmod 777 /root/stop.sh /root/start.sh
clear
echo "========================================================================="
echo "AutoVPN v10.0.0 for Linux Written by badb0y "
echo "========================================================================="
echo "sotp&start script :/root/stop.sh and /root/start.sh"
echo "Please look readme.txt"
echo "========================================================================="
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment