#!/bin/bash
#

## Firewall Script
#  01-07-26  by Erik Wegner
#  forwarding-mail-up <ExternalInterface> <MailIP>
#

EXT=$1
mail=$2

if test -z $1 || test -z $2 ; then
	echo "forwarding-mail-up <ExternalInterface> <MailIP>"
	echo "e.g.: forwarding-mail-up ippp0 194.24.1.133"
	exit 2
fi

# Pfad zu IPTables
if test -z $IPTABLES ; then
	IPTABLES=/usr/sbin/iptables
fi

# Ports
P_HIGH=1024:65535
P_SMTP=25
P_POP3=110

echo "Forwarding [$P_SMTP, $P_POP3] <-> $EXT ..."

# SMTP

$IPTABLES -A FORWARD -o $EXT \
	-m state --state NEW \
	-p TCP --sport $P_HIGH \
	-d $mail --dport $P_SMTP \
	-j ACCEPT

$IPTABLES -A FORWARD -o $EXT \
	-m state --state NEW \
	-p TCP --sport $P_HIGH \
	-d $mail --dport $P_POP3 \
	-j ACCEPT

