'state' match and ICMP time-exceeded
I found a problem in 'state' match. This problem may affects 'traceroute' command.
Consider this network:
+-------+
| host1 |
+-------+
| 192.168.0.1
|-----+-------------+----| 192.168.0.0/24
| eth0,192.168.0.1
+-------+
| host0 |
+-------+
| eth1,192.168.1.1
|-----+-------------+----| 192.168.1.0/24
| 192.168.1.2
+-------+
| host2 |
+-------+All hosts are Linux kernel 2.4.18 (RedHat 7.3). I try to test kernel 2.5.47 but failed due to build error.
First, I add the following rule in host0:
[root@host0]# iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
this makes Linux a NAT box. It does work, of course.
Second, I add the following rule:
[root@host0]# iptables -A OUTPUT -o eth0 -m state --state INVALID \
-p icmp --icmp-type time-exceeded -j LOGand run 'traceroute' command at host1:
[root@host1]# traceroute 192.168.1.2
then, traceroute first sends some packets whose TTL is one. These packets are caught by NAT box and the NAT sends ICMP time-exceeded message back to host1. So, result of 'traceroute' should be like:
traceroute to 192.168.1.2 (192.168.1.2), 30 hops max, 38 byte packets
1 192.168.0.1 1.563 ms 1.239 ms 2.036 ms
2 192.168.1.2 3.066 ms 2.355 ms 2.998 msHowever, these time-exceeded messages match the logging rule and kernel displays following log although this packet is completely VALID.
IN= OUT=eth0 SRC=192.168.0.1 DST=192.168.0.2 LEN=66 TOS=0x00 PREC=0xC0
TTL=255 ID=32423 PROTO=ICMP TYPE=11 CODE=0 [SRC=192.168.0.2 DST=192.168.1.2
LEN=38 TOS=0x00 TTL=1 ID=16053 PROTO=UDP SPT=1030 DPT=33435 LEN=18 ]So, if I add the following rule, 'traceroute' reports that first router does not send ICMP time-exceede message back. This must be a bug.
[root@host0]# iptables -A INPUT -m state --state INVALID -j DROP
[root@host0]# iptables -A OUTPUT -m state --state INVALID -j DROP
[root@host0]# iptables -A FORWARD -m state --state INVALID -j DROP [root@host1]# traceroute 192.168.1.2
traceroute to 192.168.1.2 (192.168.1.2), 30 hops max, 38 byte packets
1 * * *
2 192.168.1.2 3.066 ms 2.355 ms 2.998 ms
[root@host1]#If no NATing rule is given to host0, this problem does not occur.
+---------------------------------------------------------------+
/ UMEZAWA Takeshi (FAMILY Given) <[email protected]> /
+---------------------------------------------------------------+
Quoted 1 line · On Tue, 19 Nov 2002 23:25:02 +0900 UMEZAWA Takeshi…
If no NATing rule is given to host0, this problem does not occur.
Sorry, I have misread my memo of test result.
This problem does occur without NATing rule.
The problem is probably not related to NAT.
+---------------------------------------------------------------+
/ UMEZAWA Takeshi (FAMILY Given) <[email protected]> /
+---------------------------------------------------------------+