8 | | ---Script will be added tonight 22-07-2008--- |
| 9 | #!/bin/bash |
| 10 | networkname="vpn.local" |
| 11 | vuurmuur="vuurmuur_script" |
| 12 | interface=$1 |
| 13 | ipaddress=$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. |
| 34 | interfaces=`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. |
| 37 | for current_interface in ${interfaces[@]} |
| 38 | do |
| 39 | if [ "$current_interface" != "$interface" ] |
| 40 | then |
| 41 | current_interfaces=("${current_interfaces[@]}" $current_interface) |
| 42 | fi |
| 43 | done |
| 44 | #now add our interface to the current interfaces. |
| 45 | current_interfaces=("${current_interfaces[@]}" $interface) |
| 46 | |
| 47 | #Loop through the current interfaces. The first entry should overwrite, the rest should be appended. |
| 48 | for (( i = 0 ; i < ${#current_interfaces[@]} ; i++ )) |
| 49 | do |
| 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 |
| 60 | done |
| 61 | |
| 62 | #apply the changes by restarting the /etc/init.d/vuurmuur process. |
| 63 | /etc/init.d/vuurmuur restart |
| 64 | |
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. |
| 82 | interfaces=`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. |
| 85 | for current_interface in ${interfaces[@]} |
| 86 | do |
| 87 | if [ "$current_interface" != "$interface" ] |
| 88 | then |
| 89 | current_interfaces=("${current_interfaces[@]}" $current_interface) |
| 90 | fi |
| 91 | done |
| 92 | |
| 93 | if [ ${#current_interfaces} -eq 0 ] |
| 94 | then |
| 95 | #Remove all interfaces |
| 96 | $vuurmuur -M -n $networkname -V INTERFACE -S "" |
| 97 | else |
| 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 |
| 111 | fi |
| 112 | |
| 113 | #apply the changes by restarting the /etc/init.d/vuurmuur process. |
| 114 | /etc/init.d/vuurmuur restart |
| 115 | |