23 августа 2012 г.

О том как я настраивал VPN клиента на FreeBSD 7.0

RC.CONF > > >

hostname="VPN-Client"

ifconfig_ed0="inet 192.168.0.1  netmask 255.255.255.0" #local
ifconfig_ed1="inet 192.168.1.2  netmask 255.255.255.0" #inet


keymap="ru.koi8-r"

sshd_enable="YES"
inetd_enable="YES"

gateway_enable="YES"


#IPFW
firewall_enable="YES"
firewall_script="/etc/fw.sh"


#VPN
mpd_enable="YES"


#NAT
natd_enable="YES"
natd_interface="192.168.11.X"


#PPPoE
ppp_enable="YES"
ppp_mode="ddial"
ppp_profile="stbur"


IPFW > > >

#!/bin/sh
ipfw -q -f flush
cmd="ipfw -q add"
localip="192.168.X.0/24"
gwvpn="192.168.11.1"
ipvpn="192.168.11.XX"
stbur="92.126.128.0/20,87.103.160.0/21,90.188.32.0/19,92.124.192.0/19,95.188.192"
burnet="212.0.64.0/19"
overlink="212.0.83.46,90.188.36.209,92.124.202.228"
ipclient="212.0.93.XX"
dns="212.0.65.2"

#$cmd deny ip from any to $localip
#$cmd deny ip from $localip to any

$cmd allow ip from me to $overlink via $ipclient
$cmd allow ip from $overlink to me via $ipclient

$cmd allow ip from me to $dns via $ipclient
$cmd allow ip from $dns to me via $ipclient

$cmd allow ip from me to $gwvpn via $ipclient
$cmd allow ip from $gwvpn to me via $ipclient

$cmd allow ip from me to $ipvpn via $ipclient
$cmd allow ip from $ipvpn to me via $ipclient

$cmd allow ip from $localip to me via 192.168.0.1
$cmd allow ip from me to $localip via 192.168.0.1

$cmd deny ip from me to any via $ipclient
$cmd deny ip from any to me via $ipclient

$cmd divert 8668 ip from $localip to any
$cmd fwd $gwvpn ip from $ipvpn to any
$cmd divert 8668 ip from any to $ipvpn


MPD.CONF > > >

default:
< Табуляция > load vpn

vpn:
< Табуляция > new vpn vpn
< Табуляция > set iface disable on-demand
< Табуляция > set iface idle 0
< Табуляция > set auth authname "XXXXXX"
< Табуляция > set auth password "YYYYYY"
< Табуляция > set link keep-alive 0 0
< Табуляция > set bundle enable compression
< Табуляция > set ccp yes mppc
< Табуляция > set ccp yes mpp-e40
< Табуляция > set ccp yes mpp-e128
< Табуляция > set bundle enable crypt-reqd
< Табуляция > open

MPD.LINKS > > >

vpn:
< Табуляция > set phys type pptp
< Табуляция > set pptp peer XX.XXX.XX.XXX #Адрес VPN сервера
< Табуляция > set pptp enable originate incoming outcall



RM > > >

#!/bin/sh
rm /var/log/cron.0.bz2
rm /var/log/cron.1.bz2
rm /var/log/cron.2.bz2
rm /var/log/cron.3.bz2

rm /var/log/maillog.0.bz2
rm /var/log/maillog.1.bz2
rm /var/log/maillog.2.bz2
rm /var/log/maillog.3.bz2

rm /var/log/messages.0.bz2
rm /var/log/messages.1.bz2
rm /var/log/messages.2.bz2
rm /var/log/messages.3.bz2

rm /var/log/sendmail.st.0
rm /var/log/sendmail.st.1
rm /var/log/sendmail.st.2
rm /var/log/sendmail.st.3

rm /var/log/ppp.log.0.bz2
rm /var/log/ppp.log.1.bz2
rm /var/log/ppp.log.2.bz2

rm /var/log/xferlog.0.bz2
rm /var/log/xferlog.1.bz2
rm /var/log/xferlog.2.bz2


cp /var/log/f/httpd-access.log /var/log/httpd-access.log
cp /var/log/f/httpd-error.log /var/log/httpd-error.log


rm cvsup.log.0.gz
rm cvsup.log.1.gz
rm cvsup.log.2.gz
rm cvsup.log.3.gz
rm cvsup.log.4.gz
rm cvsup.log.5.gz

rm cvsupd.log.0.gz
rm cvsupd.log.1.gz
rm cvsupd.log.2.gz
rm cvsupd.log.3.gz
rm cvsupd.log.4.gz
rm cvsupd.log.5.gz

TESTINET > > >

#!/bin/sh

nr=""
ni=""

while !(test $ni)
 do
   is=`/sbin/ping -c 5 192.168.11.1 | grep -c "64 bytes"`
   if !(test $is -gt "0")
    then
        /usr/local/etc/scripts/rebmodem.sh

        if !(test $nr)
         then
             nr=1
             timeobr=`date`
        fi
        sleep 50

        reboot

        sleep 7
    else
        if (test $nr)
         then
            touch /tmp/inetanebylo
         fi
        ni=1
   fi
done

IFC > > >

#!/bin/sh

/sbin/ifconfig > /tmp/ifc-company
/usr/bin/ftp -u ftp://USERS:PASSW@212.0.XX.XX/ifc-company /tmp/ifc-company

[B][COLOR=teal]CRON > > > [/COLOR][/B]

*/5     *       *       *       *       root    /usr/local/etc/scripts/ifc.sh
#
#
*/2     *       *       *       *       root    /usr/local/etc/scripts/testinet.sh
#
#
*/5     *       *       *       *       root    /usr/local/etc/scripts/rm.sh.sh
#
#