#!/bin/sh
################################################################
#  Script zur Erzeugung von Firewall Regeln fuer einen
#  Linux Firewall (siehe c't 6/97, S.322)
#
#  Benoetigt die Datei "fw.inc" im aktuellen Directory
#  Aufruf mit:
#
#  # fw.txt > rules
#
#  Autor: Ralp Rudolf
#  Copyright by c't
#
#  Benutzung auf eigene Gefahr
#
################################################################


echo "# Automatisch generierte Regeln"
echo "# (c) c't magzin 6/97"


################################################################
# Firewall-Funktionen als Includedatei laden
. ./fw.inc
################################################################


################################################################
# Definition einiger Variablen (optional, aber ntzlich)
################################################################
#
# Liste aller IP-Adressen des Rechners, auf dem der Firewall
# installiert ist (eine Adresse pro NW-Karte)
myself="999.999.999.999"

# Liste aller Dialup-Interfaces (ipppx) und aller NW-Interfaces (ethx)
ipppx="ippp0 ippp1"					# ISDN-Dialup-Interfaces
ethx="eth0 eth1"					# LAN-Karten

# Bezeichnung der internen Netze
lan0="999.999.999.999/24"			# Offizielle IP-Adressen
lan1="192.168.20.0/24"				# Inoffizielle Adressen, intern


################################################################
# Regeln zur Vorbeugung gegen "IP-Spoofing"
################################################################
# 
# Syntax:
#   $spoofprotect "Nicht akzeptable Adressen" "Interfaces"
#
$spoofprotect "$myself $localhost $specials" "$ipppx eth0"
$spoofprotect "$myself $localhost"           "$eth1"


################################################################
# Regeln zu Diensten, die der Firewall-Rechner
# von anderen Adressen in Anspruch nimmt
################################################################
#
# Syntax:
#   $accept incoming   "PORT" from "IP-Liste"
#   $accept outgoing   "PORT" to   "IP-Liste"
#   $accept in_and_out "PORT" with "IP-Liste"
#
#   $deny   incoming   "PORT" from "IP-Liste"
#   $deny   outgoing   "PORT" to   "IP-Liste"
#   $deny   in_and_out "PORT" with "IP-Liste"
#
#   $reject incoming   "PORT" from "IP-Liste"
#   $reject outgoing   "PORT" to   "IP-Liste"
#   $reject in_and_out "PORT" with "IP-Liste"
#

$accept in_and_out domain with "dns.my.provider.com $lan0 $lan1"
$accept incoming telnet from "$lan0 $lan1"
$accept outgoing telnet to "$all"
$accept outgoing ftp to "$all"
$accept outgoing ping to "$all"
$accept outgoing tcp_unpriv to "$all"
$accept outgoing udp_unpriv to "$all"

################################################################
# Regeln zur Weiterleitung von IP-Paketen
################################################################
#
# Syntax:
#   $accept forwarding "PORT" from "IP-Liste" to "IP-Liste"
#   $accept forwarding "PORT" between "IP-Liste" and "IP-Liste"
#
#   $masquerade forwarding "PORT" from "IP-Liste" to "IP-Liste"
#   $masquerade forwarding "PORT" between "IP-Liste" and "IP-Liste"
#
$accept forwarding all between localhost and localhost
$masquerade forward www from "$all" to "$lan1"
$masquerade forward ftp from "$all" to "$lan1"

# Nach Auskommentierung der folgenden Zeilen knnen alle IP-Pakete
# die Firewall passieren (also VORSICHT!!!). Alle Pakete, fr die
# noch keine Firewall-Regel existiert, werden im syslog protokolliert.
# (ntzliches Hilfsmittel whrend der Firewall-Einrichtung).
# $rule "-Ia accept -o -S 0/0 -D 0/0"
# $rule "-Fa accept -o -S 0/0 -D 0/0"
# $rule "-Oa accept -o -S 0/0 -D 0/0"
