Traffic going out wrong interface
Greetings all,
I'm running into a weird bug/feature that is not causing problems per se', but I thought I would pass it along to see if anyone has run into the same.
I'm using SNAT and DNAT for some one to one mappings on some internal addresses. Here are examples of the appropriate rules:
iptables -t nat -A PREROUTING -d 64.179.20.65 -j DNAT --to-destination 192.168.1.6 iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.7 -j SNAT --to-source 64.179.20.66 iptables -t nat -A PREROUTING -d 64.179.20.66 -j DNAT --to-destination 192.168.1.7 iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 64.179.20.22
What I'm seeing on the internal network (192.168.1.0/24) on occasion is this:
23:46:50.091784 arp who-has 192.168.1.7 tell 64.179.20.66
0x0000 0001 0800 0604 0001 0050 8beb 5976 40b3 .........P..Yv@. 0x0010 1442 0000 0000 0000 c0a8 0107 0000 0000 .B.............. 0x0020 0000 0000 0000 0000 0000 0000 0000 ..............
23:47:08.698954 arp who-has 192.168.1.6 tell 64.179.20.65
0x0000 0001 0800 0604 0001 0050 8beb 5976 40b3 .........P..Yv@. 0x0010 1441 0000 0000 0000 c0a8 0106 0000 0000 .A.............. 0x0020 0000 0000 0000 0000 0000 0000 0000 ..............
So the firewall is ARPing for the private address and asking it to respond to the DNAT address mapped above. Hummm...
Here is another time I'm seeing this type of traffic:
iptables -A FORWARD -i eth0 -p tcp --tcp-flags ALL SYN,ACK -j LOG --log-prefix " SYNACK_FALLOUT " iptables -A FORWARD -i eth0 -p tcp --tcp-flags ALL SYN,ACK -j REJECT --reject-with tcp-reset
(yes these rules show up _after_ I process the state table. Its to make spoofing my IP address space less useful for SYN flooding ;)
And what I'm seeing on the internal network on occasion is this:
01:46:44.909145 64.179.20.65.1881 > 205.158.107.16.80: R [tcp sum ok] 1192820737:1192820737(0) win 0 (DF) (ttl 255, id 0, len 40)
0x0000 4500 0028 0000 4000 ff06 ee2c 40b3 1441 E..(..@....,@..A 0x0010 cd9e 6b10 0759 0050 4719 0001 0000 0000 ..k..Y.PG....... 0x0020 5004 0000 d37a 0000 0000 0000 0000 P....z........
02:05:54.646567 64.179.20.66.1525 > 205.158.107.16.80: R [tcp sum ok] 149880833:149880833(0) win 0 (DF) (ttl 255, id 0, len 40)
0x0000 4500 0028 0000 4000 ff06 ee2b 40b3 1442 E..(..@[email protected] 0x0010 cd9e 6b10 05f5 0050 08ef 0001 0000 0000 ..k....P........ 0x0020 5004 0000 1308 0000 0000 0000 0000 P.............
So the RST is getting transmitted out the wrong interface. Please note that 99.9% of the time this all works fine. It only happens every now and then (maybe once out of every 300-500 SYN/ACK packets seen).
I never see any other external packets going out the internal interface. Its only ARP requests and RST packets. BTW, this is one of the few rules I use to issue a bogus RST (only other is TCP/113 requests). Most of my rules kick back ICMP host unreachables, and I never see those on the internal network. It might mean something, it might not. Just thought I would include it to complete the info. :)
Some config info:
Hardware - Compaq Proliant; 1.2 GHz Intel; 512 MB RAM WAN link is 768 Kb
Internal net is 100 Mb switched
Kernel version - 2.4.20-20.7
iptables version - 1.2.8
Any and all thoughts are greatly appreciated,
Chris
On Tue, Aug 26, 2003 at 07:00:28AM -0400, Chris Brenton spoke thusly:
(snip)
Quoted 7 lines
23:47:08.698954 arp who-has 192.168.1.6 tell 64.179.20.65
0x0000 0001 0800 0604 0001 0050 8beb 5976 40b3 .........P..Yv@. 0x0010 1441 0000 0000 0000 c0a8 0106 0000 0000 .A.............. 0x0020 0000 0000 0000 0000 0000 0000 0000 ..............So the firewall is ARPing for the private address and asking it to respond to the DNAT address mapped above. Hummm...
Hi Chris,
I think this behaviour is a documented kernel issue. I've read (but since forgotten) reasons as to why it works this way and am too lazy to search again.
http://lists.insecure.org/lists/linux-kernel/2001/Sep/3252.html
ARP requests go out on all interfaces, and can be received on all interfaces also. The patch linked above (when I tried last) does not apply cleanly to any of the recent kernel sources. This becomes a problem when you've got all the ethernet links plugged into the same switch/hub (depending on your rulesets) and ARP races.
That is if I'm understanding your question properly.
(snip more rulesets)
Quoted 8 lines
01:46:44.909145 64.179.20.65.1881 > 205.158.107.16.80: R [tcp sum ok] 1192820737:1192820737(0) win 0 (DF) (ttl 255, id 0, len 40)
0x0000 4500 0028 0000 4000 ff06 ee2c 40b3 1441 E..(..@....,@..A 0x0010 cd9e 6b10 0759 0050 4719 0001 0000 0000 ..k..Y.PG....... 0x0020 5004 0000 d37a 0000 0000 0000 0000 P....z........02:05:54.646567 64.179.20.66.1525 > 205.158.107.16.80: R [tcp sum ok] 149880833:149880833(0) win 0 (DF) (ttl 255, id 0, len 40)
Quoted 7 lines
0x0000 4500 0028 0000 4000 ff06 ee2b 40b3 1442 E..(..@[email protected] 0x0010 cd9e 6b10 05f5 0050 08ef 0001 0000 0000 ..k....P........ 0x0020 5004 0000 1308 0000 0000 0000 0000 P.............So the RST is getting transmitted out the wrong interface. Please note that 99.9% of the time this all works fine. It only happens every now and then (maybe once out of every 300-500 SYN/ACK packets seen).
Are you running 'tcpdump' on the firewall/routing device itself ? I think a number of us have noticed rather odd things in regards to snat/dnat addresses when running tcpdump on the firewall itself.
Quoted 2 lines
I never see any other external packets going out the internal interface. Its only ARP requests and RST packets. BTW, this is one of the few rules
HTH.
Hello Julian,
Quoted 2 lines · Julian Gomez
I think this behavior is a documented kernel issue.
Thanks for the link, I'll check it out.
Quoted 2 lines
ARP requests go out on all interfaces, and can be received on all interfaces also
What I found weird was that there is no legitimate "communication" reason for the legal NAT address to be ARPing for the private NAT address, at least not that I can think of. Also, I don't *think* this is a "ARP being seen off of all interfaces" problem, as I would expect to see ARPs for the external gateway on the internal network if it was and I never see these. Its always the legal NAT to private NAT address.
Quoted 3 lines
Are you running 'tcpdump' on the firewall/routing device itself ? I think a number of us have noticed rather odd things in regards to snat/dnat addresses when running tcpdump on the firewall itself.
Hummm. I'm not running tcpdump, but I am running Snort which would have the same effect on the interface. Let me shut Snort down for a while and see if the problem goes away. If it does turn out to be Snort, that would be kind of weird as well as I've run this config since last fall. I did recently upgrade to Snort 2.0 however, so maybe something that's changed in Snort from 1.9 --> 2.0 is causing it.
Thanks for the help!
Chris
On Tue, Aug 26, 2003 at 12:21:05PM -0400, Chris Brenton spoke thusly:
Quoted 6 lines
What I found weird was that there is no legitimate "communication" reason for the legal NAT address to be ARPing for the private NAT address, at least not that I can think of. Also, I don't *think* this is
a "ARP being seen off of all interfaces" problem, as I would expect to see ARPs for the external gateway on the internal network if it was and I never see these. Its always the legal NAT to private NAT address.
Yes. That would be odd. That said, I've personally seen these ARPs on all interfaces issue cause odd (*) packet drops when we were debugging our firewall previously. At that time, I was rather daft and had both the internal & external ethernet cables plugged into the same 10Mbit hub.
(*) Odd until we figured out the problem. Its been documented on this
netfilter list a couple of times also.
Quoted 10 lines
Quoted 3 lines
Are you running 'tcpdump' on the firewall/routing device itself ? I think a number of us have noticed rather odd things in regards to snat/dnat addresses when running tcpdump on the firewall itself.
Hummm. I'm not running tcpdump, but I am running Snort which would have the same effect on the interface. Let me shut Snort down for a while and see if the problem goes away. If it does turn out to be Snort, that would be kind of weird as well as I've run this config since last fall. I did recently upgrade to Snort 2.0 however, so maybe something that's changed in Snort from 1.9 --> 2.0 is causing it.
(snip rest)
I know its bad form to reply to one's own e-mail, but I have some additional info:
I tried disabling Snort on the firewall but the problem remained. Then for kicks I changed the REJECT rule to kick back host unreachables rather than TCP resets. Everything works fine now, even with Snort running on the firewall again.
So it appears that something about having iptables kick back RST's rather than type 3's caused the bogus ARP packets as well as the RST being transmitted out the wrong interface as I described below. I'm not sure if I'm the only one having this problem, but then again I'm not sure how many people scrutinize layer 2 as deeply as I do. ;-)
Thanks for the feedback,
Chris
Quoted 62 lines · Chris Brenton
Greetings all,
I'm running into a weird bug/feature that is not causing problems per se', but I thought I would pass it along to see if anyone has run into the same.
I'm using SNAT and DNAT for some one to one mappings on some internal addresses. Here are examples of the appropriate rules:
iptables -t nat -A PREROUTING -d 64.179.20.65 -j DNAT --to-destination 192.168.1.6 iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.7 -j SNAT --to-source 64.179.20.66
iptables -t nat -A PREROUTING -d 64.179.20.66 -j DNAT --to-destination 192.168.1.7 iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 64.179.20.22What I'm seeing on the internal network (192.168.1.0/24) on occasion is this:
23:46:50.091784 arp who-has 192.168.1.7 tell 64.179.20.66
0x0000 0001 0800 0604 0001 0050 8beb 5976 40b3 .........P..Yv@. 0x0010 1442 0000 0000 0000 c0a8 0107 0000 0000 .B.............. 0x0020 0000 0000 0000 0000 0000 0000 0000 ..............23:47:08.698954 arp who-has 192.168.1.6 tell 64.179.20.65
0x0000 0001 0800 0604 0001 0050 8beb 5976 40b3 .........P..Yv@. 0x0010 1441 0000 0000 0000 c0a8 0106 0000 0000 .A.............. 0x0020 0000 0000 0000 0000 0000 0000 0000 ..............So the firewall is ARPing for the private address and asking it to respond to the DNAT address mapped above. Hummm...
Here is another time I'm seeing this type of traffic:
iptables -A FORWARD -i eth0 -p tcp --tcp-flags ALL SYN,ACK -j LOG --log-prefix "
SYNACK_FALLOUT"
iptables -A FORWARD -i eth0 -p tcp --tcp-flags ALL SYN,ACK -j REJECT --reject-with tcp-reset(yes these rules show up _after_ I process the state table. Its to make spoofing my IP address space less useful for SYN flooding ;)
And what I'm seeing on the internal network on occasion is this:
01:46:44.909145 64.179.20.65.1881 > 205.158.107.16.80: R [tcp sum ok] 1192820737:1192820737(0) win 0 (DF) (ttl 255, id 0, len 40)
0x0000 4500 0028 0000 4000 ff06 ee2c 40b3 1441 E..(..@....,@..A 0x0010 cd9e 6b10 0759 0050 4719 0001 0000 0000 ..k..Y.PG....... 0x0020 5004 0000 d37a 0000 0000 0000 0000 P....z........02:05:54.646567 64.179.20.66.1525 > 205.158.107.16.80: R [tcp sum ok] 149880833:149880833(0) win 0 (DF) (ttl 255, id 0, len 40)
0x0000 4500 0028 0000 4000 ff06 ee2b 40b3 1442 E..(..@[email protected] 0x0010 cd9e 6b10 05f5 0050 08ef 0001 0000 0000 ..k....P........ 0x0020 5004 0000 1308 0000 0000 0000 0000 P.............So the RST is getting transmitted out the wrong interface. Please note that 99.9% of the time this all works fine. It only happens every now and then (maybe once out of every 300-500 SYN/ACK packets seen).
I never see any other external packets going out the internal interface. Its only ARP requests and RST packets. BTW, this is one of the few rules I use to issue a bogus RST (only other is TCP/113 requests). Most of my rules kick back ICMP host unreachables, and I never see those on the internal network. It might mean something, it might not. Just thought I would include it to complete the info. :)
Some config info:
Hardware - Compaq Proliant; 1.2 GHz Intel; 512 MB RAM WAN link is 768 Kb
Internal net is 100 Mb switched
Kernel version - 2.4.20-20.7
iptables version - 1.2.8Any and all thoughts are greatly appreciated,
Chris
Hi Chris,
Quoted 5 lines
So it appears that something about having iptables kick back RST's rather than type 3's caused the bogus ARP packets as well as the RST being transmitted out the wrong interface as I described below. I'm not sure if I'm the only one having this problem, but then again I'm not sure how many people scrutinize layer 2 as deeply as I do. ;-)
If it is the same problem as the RSTs (which looks likely, given the symptoms), you could try applying the latest patch-o-matic, or at least submitted/66_netfilter-policy-routing.patch.
Cheers, Chris.
Signature · 4 lines
___ __ _ / __// / ,__(_)_ | Chris Wilson -- UNIX Firewall Lead Developer | / (_ / ,\/ _/ /_ \ | NetServers.co.uk http://www.netservers.co.uk | \ _//_/_/_//_/___/ | 21 Signet Court, Cambridge, UK. 01223 576516 |
On Wed, 10 Sep 2003 17:51:57 +0100 (BST), Chris Wilson <[email protected]> wrote in message <Pine.LNX.4.44.0309101747300.23381-100000@localhost>:
Quoted 8 lines
Hi Chris,
Quoted 5 lines
So it appears that something about having iptables kick back RST's rather than type 3's caused the bogus ARP packets as well as the RST being transmitted out the wrong interface as I described below. I'm not sure if I'm the only one having this problem, but then again I'm not sure how many people scrutinize layer 2 as deeply as I do. ;-)
Quoted 5 lines
If it is the same problem as the RSTs (which looks likely, given the symptoms), you could try applying the latest patch-o-matic, or at least
submitted/66_netfilter-policy-routing.patch.Cheers, Chris.
..not this bug again?:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=89171
Signature · 4 lines
..med vennlig hilsen = with Kind Regards from Arnt... ;-) ...with a number of polar bear hunters in his ancestry... Scenarios always come in sets of three: best case, worst case, and just in case.