VPN settings linux - On-line documentation - Satellite internet
This documentation it is provided as it and we do not assume any responsibility over it.
PLAIN TEXT VERSION
***********************************************************************
*** Documentation for establishing a LINUX VPN with BizarNet ***
*** Linux ***
*** Made By Cristian Raica (chris@sar.ro) ***
***********************************************************************
#!/bin/bash
# by Cristian Raica (:Chris Remy:) chris@sar.ro 06/2002
# Works on linux kernel >= 2.4
# Run this script as root
# You need (pptp) (ip) (squid)
# Configuration of dvb is standard
# This is for routing packets to vpn only for proxy web
# (squid on gateway server)
# All other trafic is normal routing to default gateway (eth0)
# Conect to server pptp with user xxx (your user account)
/sbin/pptp hsi.xanticbroadband.com user xxx
echo wait 10 seconds ...
sleep 10
# Get the local and remote IP of vpn
LOCALIP=`ip route show dev ppp0 | awk '{print $7}'`
REMOTEIP=`ip route show dev ppp0 | awk '{print $1}' `
# if no dev ppp0 exit
if [ "$LOCALIP" == "" ]; then
echo ppp0 not found.
exit 1
fi
echo Local IP : $LOCALIP
echo Remote IP : $REMOTEIP
echo -------------------
# This is the magic
# Put in /etc/iproute2/tables this line
# 200 vpn
# Add the default route for vpn the new gateway of remoteip on dev ppp0
ip route add default table vpn dev ppp0 via $REMOTEIP
ip route show table vpn
ip route flush cache
# Save old IP for first time run this not exist; don't worry;
OLDIP=`ip rule | awk '{ if ($5=="vpn") {print $3}}'`
# erase the old rule and add the new rule ( becose not exist the command
# replace)
ip rule del from $OLDIP pref 200 table vpn
# Add this new rule : all packets with source IP = LOCALIP routing ->
# REMOTEIP (table vpn)
ip rule add from $LOCALIP pref 200 table vpn
ip rule show
# This is for squid change the line tcp_outgoing_address aaa.bbb.ccc.ddd
# ( the local ip of vpn)
cat /etc/squid/squid.conf |
awk -vLIP=$LOCALIP '{ if ($1=="tcp_outgoing_address")
{ $2=LIP;}; print $0; } ' > /tmp/squid.tmp ; mv -f /tmp/squid.tmp
/etc/squid/squid.conf
service squid restart
# And this is for keep alive the vpn conection every 10 minutes
# add in crontab
# 0-59/10 * * * * root /bin/ping -c 3 -I ppp0 remoteip
cat /etc/crontab | awk -vRIP=$REMOTEIP '{ if ($7=="/bin/ping")
{ $12=RIP;}; print $0; } ' > /tmp/crontab ; mv -f /tmp/crontab /etc/crontab
# that's not all
|