Mon Motha's IPTables Firewall Configuration Reference Guide
Notation Conventions Used
Standard
CIDR notation is always permitted when an IP address is called for. This may be used to specify that a rule shall apply to an entire network rather than a single host.
Network/Mask notation is also permitted, though
CIDR is usually more readable and easier for the “networking gurus” to understand should you need to ask for help
LOCIP option: See bottom
When specifying multiple parameters for an option, separate with a space.
The script currently parses by simply setting IFS and running the fields in order; all fields of an option not specifically specified as optional are required. 0/0 may be used if you wish to specify any host; 0-65535 can be used to specify any port.
iptables standard start:stop format for port ranges is allowed for some options (not port forwards though), but all options accept start-stop as of 2.3.8-pre7. It is preferred to use start-stop rather than start:stop when specifying a portrange.
Main Configuration Section
IPTABLES=“/usr/local/sbin/iptables”
TCP_ALLOW=““
TCP ports to allow on incoming connections to the firewall itself (localhost) from the Internet. Add only the ports that you need for services like SSHD, Web Servers,
FTP servers, etc. Seperate port numbers with spaces like “22 80 443” Keep this as short as possible for security. These also apply to any computers behind the firewall that have public IPs.
-
UDP_ALLOW=“68 6112 6119 4000”
UDP ports to allow on incoming connections to the firewall itself (localhost). The defaults are what you need to play all battle.net games (including
Starcraft and Diablo ][) and to act as a DHCP client if the connection tracker fails. These also apply to any computers behind the firewall.
-
INET_IFACE=“eth0”
Interface device to the Internet. (probably eth1 or eth0 for cable, leased line, and non PPPoE DSL; ppp0 for dialup or PPPoE DSL)
As of 2.3.8-pre8, multiple interfaces are permitted here
-
LAN_IFACE=“eth1”
INTERNAL_LAN=“192.168.0.0/24 192.168.1.0/24”
The ENTIRE internal
LAN. (If you have multiple subnet's, separate with spaces). This should also set up all you need to use the firewall box as a router between subnets (assuming your routing table is properly configured).
/24 means subnet 255.255.255.0,
/8 is 255.0.0.0 (for 10.x.x.x). See
CIDR Notation
The INTERNAL_
LAN is completely trusted, see above.
-
MASQ_LAN=“192.168.0.0/24 192.168.1.0/24”
SNAT_LAN=”“
DROP=“TREJECT”
DENY_ALL=”“
DENY_HOSTWISE_TCP=“192.168.1.1>110”
DENY_HOSTWISE_UDP=“192.168.1.1>27015”
BLACKHOLE=”“
BLACKHOLE_DROP=“DROP”
ALLOW_HOSTWISE_TCP=“123.123.123.123>113”
ALLOW_HOSTWISE_UDP=“123.123.123.123>68”
TCP_FW=”“
Port forwards on TCP. This allows you to forward one (or a range of ports, use a - between the start and stop ports) port from the external interface on the NAT box to the same or a different port on an internal HOST. This can also be used between public IPs. The format is: port(range) on external iface:port on internal iface>destination IP. If a range is specified, all the ports on the external interface will be forwarded incrementally to the portrange specified on the internal interface. (I.E. specify the rule “1-5:2-6>10.0.0.1”, port 1 will be forwarded to port 2 on 10.0.0.1, 2 forwards to 3, etc).
As of 2.3.8-pre3 you will also need to allow them in TCP_ALLOW or similar.
Remember, these will normally
only apply to the external interface (INET_IFACE). If you need it to apply to local interfaces as well, you
must specify a local IP address. If you are trying to get requests from your lan clients to
www.yourdomain.com to get back to your internal server,
run DNS on the lan to resolve
www.yourdomain.com to the internal server's ip.
-
UDP_FW=”“
MANGLE_TOS_OPTIMIZE=“TRUE”
This changes the TOS of various packets (mostly generated by games) to ask for special treatment by routers along the way
Often, this is silently ignored by internet routers, but some can provide different routes for high-bandwidth vs. low-latency (think gigabit satellite link vs. T1).
This has been known to cause problems; disable if you have problems or just don't like it
-
DHCP_SERVER=“FALSE”
Set to TRUE if the firewall is also a DHCP server. DHCP clients do not need this. This allows broadcasts to the server from potential clients on the
LAN to succeede.
-
BAD_ICMP=“5 9 10 15 16 17 18”
This is a list of ICMP messages to deny from the internet. Numeric or english form is acceptable. ICMP message types: 0)Echo Reply 1,2)Reserved 3)Destination Unreachable 4)Source Quench 5)Redirect 6)Alternate Host Address 7)No Info 8)Echo Request 9)Router Advertisement 10)Router Solicitation 11)Time Exceeded 12)Parameter Problem 13)Timestamp Request 14)Timestamp Reply 15)Information Request 16)Information Reply 17)Address Mask Request 18)Address Mask Reply 19-29)Reserved 30)Traceroute 31)Conversion Error (The rest are boring).
-
ENABLE=“N”
Flood Parameters Configuration
LOG_FLOOD=“2/s”
How often to log to the log file if something's happening that has logging on it (the L-policies for DROP, synfloods, ping floods). This is to prevent logs from being filled with duplicate messages. Probably should be decreased unless you are investigating things.
SYN_FLOOD=“20/s”
?Syn Cookies ). This is intended to be a “last resort” kind of option (similar to the ”!
?Max Clients” option on Apache), only meant to keep the system from spiraling down into nothingness under the brunt of an insane synflood. Set this option very high.
PING_FLOOD=“1/s”
How many pings to respond to per second. For most people 1 per second or even less is sufficient (just enough to check to see if you're up).
www.yahoo.com might want more though :)
Outbound filters
ALLOW_OUT_TCP=““
Internal hosts allowed to be forwarded out on TCP (do not put this/these host/s in INTERNAL_
LAN, but do define their method of access (snat or masq) if not a public ip). Use the source luke.
PROXY=”“
MY_IP=”“
Experimental Options (please report your successes/failures)
MAC Address stuff is broken currently; see Mon Motha Known Bugs
MAC_MASQ=”“
MAC_SNAT=”“
TTL_SAFE=”“
How many hops packets need to make once they get on your
LAN (null disables the mangling) (requires patch from patch-o-matic). Probably for extremely paranoid people only, it's only in for fun.
USE_SYNCOOKIES=“FALSE”
?Syn Cookies on or off (TRUE/FALSE toggle). Recommended to TRUE, because this will protect you from SYN floods by posing a cryptographic challenge per every TCP connection to make illegitimate connections computationally expensive, thus rendering SYN floods mostly ineffective. Requires more CPU power on your firewall machine, though not noticably so unless you have an active server or you are synflooded.
SUPER_EXEMPT=”“
A list of hosts that get to completely bypass the packet filter. Separate with spaces. Use these with extreme caution (you might as well add them to /etc/hosts.equiv while you're at it if you trust these hosts this much).
REMEMBER: IP Addresses can be spoofed!!!!
BRAINDEAD_ISP=“FALSE”
This option forces no fragments on TCP. Useful if you have an ISP with a braindead firewall that blocks ICMP fragment needed messages or if you are on a tunneled connection (such as PPPoE DSL) with an MTU lower than that of your
LAN.
ALLOW_HOSTWISE_PROTO=”“
PROTO_FW=”“
Pre-Alpha and non-functional stuff - Don't bother unless you're working on it.
LOCIP options for configuration directives
Many configuration directives allow a LOCIP option to be specified. This allows you to filter based on the destination IP. This is useful if the system running the firewall has multiple public IPs or you are running publicly routable IPs on your internal LAN and want to open ports to a single host only.
Outbound filtering
The script has very little support for outbound filters. This will be addressed in the later 2.5.x development series (not begun as of 23 June 2002).