The policies relevant to IP firewall and their meanings are:
accept
Allows matching datagrams to be received, forwarded, or transmitted
deny
Blocks matching datagrams from being received, forwarded, or transmitted
reject
Blocks matching datagrams from being received, forwarded, or transmitted, and sends the host that sent the datagram and ICMP error message
Parameters
At least one of the following must be supplied. Use the parameters to specify to which datagrams this rule applies:
- P protocol
Can be TCP, UDP, ICMP, or all. Example:
- P tcp
- S address[/mask] [port]
Source IP address that this rule will match. A netmask of '/32' will be assumed if you don't supply one. You may optionally specify which ports this rule will apply to. You must also specify the protocol using the
- S 172.29.16.1/24 ftp:ftp-data
- D address[/mask] [port]
Specify the destination IP address that this rule will match. The destination address is coded with the same rules as the source address described previously. Here is an example:
- D 172.29.16.1/24 smtp
- V address
Specify the address of the network interface on which the packet is received (
- V 172.29.16.1
- W name
Specify the name of the network interface. This argument works in the same way as the
- W ppp0
Optional arguments
These arguments are sometimes very useful:
- b
This is used for bidirectional mode. This flag matches traffic flowing in either direction between the specified source and destination. This saves you from having to create two rules: one for the forward direction of a connection and one for the reverse.
- o
This enables logging of matching datagrams to the kernel log. Any datagram that matches this rule will be logged as a kernel message. This is useful to enable you to detect unauthorized access.
- y
This is used to match TCP connect datagrams. The option causes the rule to match only datagrams that attempt to establish TCP connections. Only datagrams that have their SYN bit set, but their ACK bit unset, will match. This is useful to filter TCP connection attempts and is ignored for other protocols.
- k
This is used to match TCP acknowledgement datagrams. This option causes the rule to match only datagrams that are acknowledgements to packets attempting to establish TCP connections. Only datagrams that have their ACK bit set will match. This is useful to filter TCP connection attempts and is ignored for all other protocols.
ICMP datagram types
Each of the firewall configuration commands allows you to specify ICMP datagram types. Unlike TCP and UDP ports, there is no convenient configuration file that lists the datagram types and their meanings. The ICMP datagram types are defined in RFC-1700, the Assigned Numbers RFC. The ICMP datagram types are also listed in one of the standard C library header files. The
Table 9.2: ICMP Datagram Types
| Type Number | iptables Mnemonic | Type Description |
|---|---|---|
| 0 | echo-reply | Echo Reply |
| 3 | destination-unreachable | Destination Unreachable |
| 4 | source-quench | Source Quench |
| 5 |
