Online Book Reader

Home Category

Linux Firewalls - Michael Rash [23]

By Root 454 0
that is created by having to manage the firewall policy is well worth the effort in the face of risking potential compromise.

Testing the Policy: ICMP

Finally, we'll test the iptables policy over ICMP. The iptables commands used in the construction of the policy used the --icmp-type option to restrict acceptable ICMP packets to just Echo Request packets (the connection-tracking code allows the corresponding Echo Reply packets to be sent so an explicit ACCEPT rule does not have to be added to allow such replies). Therefore, iptables should be allowing all Echo Request packets, but other ICMP packets should be met with stark silence. We test this by generating ICMP Echo Reply packets without sending any corresponding Echo Request packets, which should cause iptables to match the packets on the INVALID state rule at the beginning of the INPUT chain. Again, we turn to hping to test from both the internal and external networks. The first test is to generate an unsolicited ICMP Echo Reply packet from the external network, and we expect that iptables will log and drop the packet in the INPUT chain. By examining the iptables log, we see that this is indeed the case (the DROP INVALID log prefix is in bold):

[ext_scanner]# hping −1 --icmptype echo-reply 71.157.X.X

HPING (eth1 71.157.X.X): icmp mode set, 28 headers + 0 data bytes

--- 71.157.X.X hping statistic ---

2 packets transmitted, 0 packets received, 100% packet loss

round-trip min/avg/max = 0.0/0.0/0.0 ms

[iptablesfw]# tail /var/log/messages |grep ICMP

Apr 14 17:04:58 iptablesfw kernel: DROP INVALID IN=eth0 OUT=

MAC=00:13:d3:38:b6:e4:00:30:48:80:4e:37:08:00 SRC=144.202.X.X DST=71.157.X.X

LEN=28 TOS=0x00 PREC=0x00 TTL=64 ID=44271 PROTO=ICMP TYPE=0 CODE=0 ID=21551

SEQ=0

Similarly, the same result is achieved from the internal network:

[int_scanner]# hping −1 --icmptype echo-reply 192.168.10.1

HPING (eth1 192.168.10.1): icmp mode set, 28 headers + 0 data bytes

--- 192.168.10.1 hping statistic ---

2 packets transmitted, 0 packets received, 100% packet loss

round-trip min/avg/max = 0.0/0.0/0.0 ms

[iptablesfw]# tail /var/log/messages |grep ICMP |tail -n 1

Apr 14 17:06:45 iptablesfw kernel: DROP INVALID IN=eth1 OUT=

MAC=00:13:46:3a:41:4b:00:a0:cc:28:42:5a:08:00 SRC=192.168.10.200

DST=192.168.10.1 LEN=28 TOS=0x00 PREC=0x00 TTL=64 ID=36520 PROTO=ICMP TYPE=0

CODE=0 ID=44313 SEQ=0

* * *

[6] 3 The set of all non-routable addresses is defined in RFC 1918. Such addresses are non-routable by convention on the open Internet.

[7] 4 Here connection is the tracking mechanism that Netfilter uses to categorize packets.

[8] 5 One thing to note about the iptables.sh script is that all of the LOG rules are built with the --log-ip-options and --log-tcp-options command-line arguments. This allows the resulting iptables syslog messages to include the IP and TCP options portions of the IP and TCP headers if the packet that matches the LOG rule contains them. This functionality is important for both attack detection and passive OS fingerprinting operations performed by psad (see Chapter 7).

[9] 6 See http://www.securityfocus.com/archive/1/375204/2004-09-09/2004-09-15/0 for more information.

[10] 7 The details regarding whether or not a RST packet has the ACK bit set are discussed in detail in Chapter 3.

Concluding Thoughts

This chapter focuses on iptables concepts that are important for the rest of the book and lays a foundation from which to begin discussing intrusion detection and response from an iptables standpoint. We are now armed with a default iptables policy and network diagram that is referenced in several upcoming chapters, and we have seen examples of iptables log messages that illustrate the completeness of the iptables logging format. We are now ready to jump into a treatment of attacks that we can detect—and thwart, as we shall see—with iptables.

Chapter 2. NETWORK LAYER ATTACKS AND DEFENSE

The network layer—layer three in the OSI Reference Model—is the primary mechanism for end-to-end routing and delivery of packet data on the Internet.

Return Main Page Previous Page Next Page

®Online Book Reader