Changes between Version 2 and Version 3 of vpn_ppp


Ignore:
Timestamp:
07/22/08 17:52:49 (13 years ago)
Author:
FrankSpierings
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • vpn_ppp

    v2 v3  
    33Vuurmuur requires you to specify the interfaces for a certain zone. This can be a problem when interfaces are created on-the-fly. For instance a PPTP server or client will create a pppX interface (where X is a number starting at 0). These interfaces should be dynamically added to vuurmuur.
    44When a pppX interface comes online scripts from the ''/etc/ppp/ip-up.d/'' directory will be executed. Parameters will be parsed which define the interface name and the interface IP-address. We can use this to dynamically create and destroy interfaces within vuurmuur.
    5 The following script will create the pppX interface and it will add it to the '''vpn.local''' network. '''PLEASE SPECIFY YOUR VPN NETWORK! '''
     5The following script will create the pppX interface and it will add it to the '''vpn.local''' network. '''PLEASE SPECIFY YOUR VPN NETWORK! networkname="vpn.local" --> '''
    66
     7''/etc/ppp/ip-up.d/vuurmuur_ppp.up''
    78{{{
    8 ---Script will be added tonight 22-07-2008---
     9#!/bin/bash
     10networkname="vpn.local"
     11vuurmuur="vuurmuur_script"
     12interface=$1
     13ipaddress=$4
     14
     15#Create the interface
     16$vuurmuur -C -i $interface
     17
     18#Setup interface rules
     19$vuurmuur -M -i $interface -V RULE -S "protect against source-routed-packets"
     20$vuurmuur -A -M -i $interface -V RULE -S "protect against icmp-redirect"
     21$vuurmuur -A -M -i $interface -V RULE -S "protect against send-redirect"
     22$vuurmuur -A -M -i $interface -V RULE -S "protect against rp-filter"
     23$vuurmuur -A -M -i $interface -V RULE -S "protect against log-martians"
     24
     25#Setup the interface options.
     26$vuurmuur -M -i $interface -V DEVICE -S $interface
     27$vuurmuur -M -i $interface -V IPADDRESS -S $ipaddress
     28$vuurmuur -M -i $interface -V VIRTUAL -S No
     29$vuurmuur -M -i $interface -V COMMENT -S "Dynamic vpn tunnel interface"
     30$vuurmuur -M -i $interface -V ACTIVE -S Yes
     31
     32#Add the interface to specified network.
     33#--First check which interfaces are already there, don't add the current interface if it is in the list.
     34interfaces=`vuurmuur_script -P -n vpn.local | grep INTERFACE | sed s/INTERFACE=\"// | sed s/\"//` #list variables | grep for INTERFACE | del INTERFACE=" | del "
     35
     36#loop through current interfaces, add these to current_interfaces array. Do not add our new interface if its already there.
     37for current_interface in ${interfaces[@]}
     38do
     39        if [ "$current_interface" != "$interface" ]
     40        then
     41                current_interfaces=("${current_interfaces[@]}" $current_interface)
     42        fi
     43done
     44#now add our interface to the current interfaces.
     45current_interfaces=("${current_interfaces[@]}" $interface)
     46
     47#Loop through the current interfaces. The first entry should overwrite, the rest should be appended.
     48for (( i = 0 ; i < ${#current_interfaces[@]} ; i++ ))
     49do
     50        if [ $i -eq 0 ]
     51        then
     52                #create
     53                $vuurmuur -M -n $networkname -V INTERFACE -S ${current_interfaces[$i]}
     54                #echo "Create: ${current_interfaces[$i]}"
     55        else
     56                #append
     57                $vuurmuur -A -M -n $networkname -V INTERFACE -S ${current_interfaces[$i]}
     58                #echo "Append: ${current_interfaces[$i]}"
     59        fi
     60done
     61
     62#apply the changes by restarting the /etc/init.d/vuurmuur process.
     63/etc/init.d/vuurmuur restart
     64
    965}}}
    1066
    11 The following script will remove the pppX interface and it will remove it from the '''vpn.local''' network. '''PLEASE SPECIFY YOUR VPN NETWORK! '''
     67The following script will remove the pppX interface and it will remove it from the '''vpn.local''' network. '''PLEASE SPECIFY YOUR VPN NETWORK! networkname="vpn.local" --> '''
    1268
     69''/etc/ppp/ip-down.d/vuurmuur_ppp.down''
    1370{{{
     71#!/bin/bash
     72networkname="vpn.local"
     73vuurmuur="vuurmuur_script"
     74interface=$1
     75ipaddress=$4
    1476
    15 ---Script will be added tonight 22-07-2008---
     77#Remove the current interface
     78$vuurmuur -D -i $interface
     79
     80#Add the interface to specified network.
     81#--First check which interfaces are already there.
     82interfaces=`vuurmuur_script -P -n vpn.local | grep INTERFACE | sed s/INTERFACE=\"// | sed s/\"//` #list variables | grep for INTERFACE | del INTERFACE=" | del "
     83
     84#loop through current interfaces, add these to current_interfaces array. Do not add our current interface.
     85for current_interface in ${interfaces[@]}
     86do
     87        if [ "$current_interface" != "$interface" ]
     88        then
     89                current_interfaces=("${current_interfaces[@]}" $current_interface)
     90        fi
     91done
     92
     93if [ ${#current_interfaces} -eq 0 ]
     94then
     95        #Remove all interfaces
     96        $vuurmuur -M -n $networkname -V INTERFACE -S ""
     97else
     98        for (( i = 0 ; i < ${#current_interfaces[@]} ; i++ ))
     99        do
     100                if [ $i -eq 0 ]
     101                then
     102                        #create
     103                        $vuurmuur -M -n $networkname -V INTERFACE -S ${current_interfaces[$i]}
     104                        #echo "Create: ${current_interfaces[$i]}"
     105                else
     106                        #append
     107                        $vuurmuur -A -M -n $networkname -V INTERFACE -S ${current_interfaces[$i]}
     108                        #echo "Append: ${current_interfaces[$i]}"
     109                fi
     110        done
     111fi
     112
     113#apply the changes by restarting the /etc/init.d/vuurmuur process.
     114/etc/init.d/vuurmuur restart
     115
    16116}}}