![]() | ![]() |
To avoid confusion, the example rules are specified with abstract descriptions, rather than with real addresses, as much as possible. Instead of using real source and destination addresses (e.g., 172.16.51.50), we use "internal" or "external" to identify which networks we're talking about. Actual packet filtering systems usually require you to specify address ranges explicitly; the syntax varies from router to router.
Although we try to be as specific as possible in these examples, it's impossible to tell you precisely what you have to specify for your particular packet filtering product. The exact mechanism for specifying packet filtering rules varies widely from product to product. Some products allow you to specify a single set of rules that are applied to all packets routed by the system. Others allow you to specify rules for particular interfaces. Still others allow you to specify sets of rules and then apply sets by name to particular interfaces (so that you might define one set of rules that is shared by a number of different interfaces, for example, and put the rules that are unique to a given interface into a different set).
Rule | Direction | Source Address | Dest. Address | ACK Set | Action |
---|---|---|---|---|---|
A | Inbound | Trusted external host | Internal | Any | Permit |
B | Outbound | Internal | Trusted external host | Any | Permit |
C | Either | Any | Any | Any | Deny |
On a Cisco router, you specify rules as sets, and apply the relevant sets to the right direction on the right interface. If your external interface is named "serial1", your rules would look like this:
The Linux ipchains rules (assuming that eth0 is the internal interface and eth1 is the external interface) would look like this:access-list 101 permit ip 172.16.51.50 0.0.0.0 192.168.10.0 0.0.0.255 access-list 101 deny ip 0.0.0.0 255.255.255.255 0.0.0.0 255.255.255.255 interface serial 1 access-group 101 in access-list 102 permit ip 192.168.10.0 0.0.0.255 172.16.51.50 0.0.0.0 access-list 102 deny ip 0.0.0.0 255.255.255.255 0.0.0.0 255.255.255.255 interface serial 1 access-group 102 out
The rules for ipfilter, which would be placed in ipf 's configuration file (assuming that le0 is the internal interface and le1 is the external interface) look like this:ipchains -P input DENY ipchains -P output DENY ipchains -P forward DENY ipchains -A input -i eth0 -s 192.168.10.0/24 -d 172.16.51.50 -j ACCEPT ipchains -A input -i eth1 -s 172.16.51.50 -d 192.168.10.0/24 -j ACCEPT ipchains -A input -l -j DENY ipchains -A output -i eth1 -s 192.168.10.0/24 -d 172.16.51.50 -j ACCEPT ipchains -A output -i eth0 -s 172.16.51.50 -d 192.168.10.0/24 -j ACCEPT ipchains -A output -l -j DENY ipchains -A forward -b -s 172.16.51.50 -d 192.168.10.0/24 -j ACCEPT ipchains -A forward -l -j DENY
Using Windows NT's Routing and Remote Access Service filtering, you would add two rules:pass in quick on le0 from 192.168.10.0/24 to 172.16.51.50 pass in quick on le1 from 172.16.51.50 to 192.168.10.0/24 pass out quick on le1 from 192.168.10.0/24 to 172.16.51.50 pass out quick on le0 from 172.16.51.50 to 192.168.10.0/24 block in all block out all
For detailed information on the syntax of a particular package or product, consult the documentation for that package or product. Once you understand the syntax for the particular system you are using, you shouldn't have too much difficulty translating from our tables to that system's syntax.
TIP: Watch out for implicit defaults. Different filtering systems have different default actions they take if a packet doesn't match any of the filtering rules specified. Some systems deny all such packets. Other systems make the default the opposite of the last rule; that is, if the last rule was a "permit", the system default is to "deny", and if the last rule was a "deny", the default is to "permit". In any case, it's a good idea to put an explicit default rule at the end of your list of packet filtering rules, so you don't have to worry about (or even remember) which implicit default your system is going to use.