2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2017 IPFire Network Development Team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 LOG_DISABLE_STDOUT
="true"
24 .
/usr
/lib
/network
/functions
26 # Read network settings
29 # Make sure we are called by strongSwan
30 assert isset PLUTO_VERSION
32 CONNECTION
="${PLUTO_CONNECTION}"
34 if ! ipsec_connection_read_config
"${CONNECTION}"; then
35 log ERROR
"Could not read configuration for ${CONNECTION}"
39 # Interface name for this IPsec connection
42 INTERFACE
="ipsec-${CONNECTION}"
46 log DEBUG
"${0} called for ${CONNECTION}: ${PLUTO_VERB}"
48 case "${PLUTO_VERB}" in
49 up-client|up-client-v6|up-host|up-host-v6
)
52 if ! device_exists
"${INTERFACE}"; then
53 ip_tunnel_add
"${INTERFACE}" \
55 --local-address="${PLUTO_ME}" \
56 --remote-address="${PLUTO_PEER}"
58 device_set_up
"${INTERFACE}"
62 if device_exists
"${INTERFACE}"; then
63 ip_tunnel_change_keys
"${INTERFACE}" \
64 --ikey="${PLUTO_MARK_IN%/*}" \
65 --okey="${PLUTO_MARK_OUT%/*}"
68 if ! ip_tunnel_add
"${INTERFACE}" \
70 --local-address="${PLUTO_ME}" \
71 --remote-address="${PLUTO_PEER}" \
72 --ikey="${PLUTO_MARK_IN%/*}" \
73 --okey="${PLUTO_MARK_OUT%/*}"; then
74 log ERROR
"Could not create VTI device for ${CONNECTION}"
78 device_set_up
"${INTERFACE}"
83 if isset INTERFACE
; then
84 cmd ip route add
"${PLUTO_PEER_CLIENT}" \
87 cmd ip route add
"${PLUTO_PEER_CLIENT}" \
92 down-client|down-client-v6|down-host|down-host-v6
)
94 cmd ip route del
"${PLUTO_PEER_CLIENT}"
99 if device_exists
"${INTERFACE}"; then
100 device_set_down
"${INTERFACE}"
102 ip_tunnel_del
"${INTERFACE}"