
#-----------------------------------------------------------------------
# Copyright (C) 2000-2001, Jean-Sebastien Morisset <jsmoriss@mvlan.net>
#-----------------------------------------------------------------------
# $Id: 050-ipsecvpn-hosts,v 1.3 2001/12/19 14:58:28 jsmoriss Exp $
#-----------------------------------------------------------------------
# README
#-----------------------------------------------------------------------
#
# This module supports the IPSec VPN, typically used by S/WAN and other
# tunneling software.
#
# To install, copy this file to /etc/firewall/modules/public/services/
# 050-ipsecvpn-hosts. Since VPN bandwidth use may be very high, it's 
# preferable to keep this module near the top. Execute rc.firewall with
# the --update-config parameter. This will add the new options to the 
# configuration file.
#
#-----------------------------------------------------------------------
# MODULE CONFIGURATION
#-----------------------------------------------------------------------
#
#m# 123
#a# accept
#i# cluster noipsec
#n# ipsecvpn
#t# hosts
#
#   |--------------------------------------------------------------------|
#d# ipsecvpn (Port 500 UDP)
#d# Hostnames of other servers you'll be communicating with via an IPSec
#d# VPN, typically used by S/WAN and other tunneling software. Entering a
#d# value here will also turn off route filtering (used to prevent IP 
#d# spoofing) on your ipsec public interface(s). Note: This module assumes
#d# you use ESP encryption and/or authentication (the typical case). For
#d# servers which use AH packet-level authentication use the ipsecvpnah
#d# ipsecvpnah. Other VPN protocols may be found in the common directory.
#d# Your IPSec interface should usually be declared PUBLIC!
#   |--------------------------------------------------------------------|
#
#-----------------------------------------------------------------------
# START OF MODULE CODE
#-----------------------------------------------------------------------

module_name="ipsecvpn"         # module name used in options
module_type="hosts"            # the module type (clients, servers, etc.)
service_name="IPSec VPN (ESP)" # displayed on-screen
service_port="500"             # port number for this service

[ "$CLUSTER_NAME" ] \
	&& { inchain="$OUTCHAIN"; outchain="$INCHAIN" ; } \
	|| { inchain="$INCHAIN" ; outchain="$OUTCHAIN"; }

for host in `Option_Value accept $INTOPT $module_name $module_type`
do
	echo "Accept $INTOPT $IPADDR $service_name <-> $host $LOG_MSG"
	ipchains -A $inchain  -j ACCEPT -p udp -s $host   $service_port -d $IPADDR $service_port $LOG
	ipchains -A $outchain -j ACCEPT -p udp -s $IPADDR $service_port -d $host   $service_port $LOG

	ipchains -A $inchain  -j ACCEPT -p 50 -s $host   -d $IPADDR $LOG
	ipchains -A $outchain -j ACCEPT -p 50 -s $IPADDR -d $host   $LOG
done
unset host inchain outchain

