4 # sa-up.sh local configuration for a new SA
6 PATH
=/bin
:/sbin
:/usr
/bin
:/usr
/sbin
:/usr
/local
/bin
:/usr
/local
/sbin
10 DEFAULT_GW
=`netstat -finet -rn | awk '($1 == "default"){print $2; exit}'`
13 DEFAULT_GW
=`netstat --inet -rn | awk '($1 == "0.0.0.0"){print $2; exit}'`
18 echo "LOCAL_ADDR = ${LOCAL_ADDR}"
19 echo "LOCAL_PORT = ${LOCAL_PORT}"
20 echo "REMOTE_ADDR = ${REMOTE_ADDR}"
21 echo "REMOTE_PORT = ${REMOTE_PORT}"
22 echo "DEFAULT_GW = ${DEFAULT_GW}"
23 echo "INTERNAL_ADDR4 = ${INTERNAL_ADDR4}"
24 echo "INTERNAL_NETMASK4 = ${INTERNAL_NETMASK4}"
25 echo "INTERNAL_DNS4 = ${INTERNAL_DNS4}"
27 echo ${INTERNAL_ADDR4} |
grep '[0-9]' > /dev
/null ||
exit 0
28 echo ${INTERNAL_NETMASK4} |
grep '[0-9]' > /dev
/null ||
exit 0
29 echo ${DEFAULT_GW} |
grep '[0-9]' > /dev
/null ||
exit 0
31 mv /etc
/resolv.conf
/etc
/resolv.conf.bak
32 ( umask 22; touch /etc
/resolv.conf
)
33 echo "# Generated by racoon on `date`" >> /etc
/resolv.conf
34 echo "nameserver ${INTERNAL_DNS4}" >> /etc
/resolv.conf
38 if=`netstat -finet -rn|awk '($1 == "default"){print $7; exit}'`
39 ifconfig
${if} alias ${INTERNAL_ADDR4} netmask ${INTERNAL_NETMASK4}
41 route add default
${DEFAULT_GW} -ifa ${INTERNAL_ADDR4}
42 route add
${REMOTE_ADDR} ${DEFAULT_GW}
45 if=`netstat --inet -rn|awk '($1 == "0.0.0.0"){print $8; exit}'`
46 ifconfig
${if}:1 ${INTERNAL_ADDR4}
48 route add
${REMOTE_ADDR} gw ${DEFAULT_GW} dev ${if}
49 route add default gw
${DEFAULT_GW} dev
${if}:1
54 REMOTE
="${REMOTE_ADDR}"
55 if [ "x${LOCAL_PORT}" != "x500" ]; then
57 LOCAL
="${LOCAL}[${LOCAL_PORT}]"
58 REMOTE
="${REMOTE}[${REMOTE_PORT}]"
63 spdadd ${INTERNAL_ADDR4}/32[any] 0.0.0.0/0[any] any
64 -P out ipsec esp/tunnel/${LOCAL}-${REMOTE}/require;
65 spdadd 0.0.0.0/0[any] ${INTERNAL_ADDR4}[any] any
66 -P in ipsec esp/tunnel/${REMOTE}-${LOCAL}/require;
70 # XXX This is a workaround for Linux forward policies problem.
71 # Someone familiar with forward policies please fix this properly.
76 spddelete 0.0.0.0/0[any] ${INTERNAL_ADDR4}[any] any
77 -P fwd ipsec esp/tunnel/${REMOTE}-${LOCAL}/require;