First Commit
[librecmc/package-feed.git] / net / ipsec-tools / files / p1client-up
1 #!/bin/sh
2 #
3
4 log="logger -t p1client-up[$$]"
5
6 . /lib/functions.sh
7 . /etc/racoon/functions.sh
8
9 if [ -z "$SPLIT_INCLUDE_CIDR" ]; then
10   $log "Connection without server-pushed routing is not supported"
11   exit 1
12 fi
13
14 $log "Setting up tunnel to server $REMOTE_ADDR"
15 $log "Making tunnel(-s) to $SPLIT_INCLUDE_CIDR through $INTERNAL_ADDR4"
16
17 get_fieldval data dev "$(/usr/sbin/ip route get $REMOTE_ADDR)"
18 ip address add $INTERNAL_ADDR4/32 dev $data
19
20 config_load racoon
21 config_get confIntZone racoon int_zone lan
22 config_get confExtZone racoon ext_zone wan
23
24 data=$(get_zoneiflist $confIntZone)
25 if [ -n "$data" ]; then
26   for item in $data ; do
27     network_get_subnet locnet $item
28     if [ -n "$locnet" ]; then
29       manage_sa add "$locnet" "$SPLIT_INCLUDE_CIDR" $REMOTE_ADDR $INTERNAL_ADDR4
30     else
31       $log "Can not find subnet on interface $item"
32     fi
33   done
34 else
35   $log "Can not find interfaces in zone $confIntZone"
36 fi
37
38 manage_fw add $confIntZone $confExtZone "$INTERNAL_ADDR4 $SPLIT_INCLUDE_CIDR"
39
40
41 # EOF /etc/racoon/p1client-up