genfw - Generate a firewall script
genfw
This script generates a firewall script based on a rules file and the network configuration of a system.
The rules file should contain one line for each interface on the system.
Like most standard Unix configuration files, \
is used to continue lines
and #
is used to begin comments.
internal
interfaceint
interfaceinternal
.
dmz
interfaceoutside
interfaceoutput
interfaceoutside
.
out
interfaceoutside
.
append
[table:]chain ruleFor example, the following would redirect outgoing connections on port 80 to port 3128 (for transparent proxying with squid):
append nat:PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to 3128
no logging
limit logging
-m limit
to all
-j LOG
lines. This is the default.
full logging
Any of the interface definition lines can include any number of the following whitespace-separated options:
ignore
allow=
port/
proto[:
src[:
dest[:
interface]]]>[,
...]allow=
portallow=domain
to allow traffic to UDP or TCP port 53.
allow=
protocolallow=gre
.
allow=
port/
protocolallow=smtp/tcp
or
allow=25/tcp
. Both are equivalent.
Any number of protocols, ports, etc. can be included after an allow=
in
a comma-separated list.
Any of the above can also be followed by a colon-separated list including the source address, destination address, and source interface. Any of the three can be left blank.
For example, allow=ssh/tcp:::eth0
would allow ssh access from eth0, but
nowhere else.
label=
labeltrusted
nat
/etc/sysconfig/rules The rules used to generate the firewall script.
/etc/sysconfig/network-scripts/ifcfg-* The network configuration.
A good firewall should restrict traffic on a per-interface basis as much as possible. This script tends to encourage this behavior...
Currently this script only knows how to read the configuration from a Red Hat system.
Steven Pritchard <steve@silug.org>
iptables(8), services(5), protocols(5)