大网数据广告活动
服务器运维问答

Do NATs rewrite ipAddress in payload of ICMP packets?

· 52CE 我爱测

Today when I test running a tracert command (windows + Wireshark) I see a outbound ICMP_ECHO_REQUEST packet that has sourceIP as "192.168.1.55" - my local IPAddress. It is followed by a ICMP_TTL_EXCEEDED packet sent from an inter…

问题原文

原帖链接 · David Tran · CC BY-SA 3.0

Today when I test running a tracert command (windows + Wireshark) I see a outbound ICMP_ECHO_REQUEST packet that has sourceIP as "192.168.1.55" - my local IPAddress.

It is followed by a ICMP_TTL_EXCEEDED packet sent from an internet wild host as reply to me that my EchoRequest packet died halfway. The reply-packet "quotes" first 28 byte of my "original packet" in the payload section where I can see the sourceIP staying "192.168.1.55" - my local ipAddress.

A question immediately pops out of my head: "The NAT did not rewrite the "local" sourceIP in IP-Header or did him rewrite it in payload "?

AFAIK in case of TCP or UDP packets, the NAT will replace the local "ip:port" with external "IP:PORT" in the IP-Header of the packet. So I am wondering:

1 - Whether NATs are replacing them in the payload section of packets? (Or just do that with ICMP packet of type TTL_Exceeded only?)

2 - If 1 is not true, is this a kind of security threat?

已采纳解答

原帖链接 · kasperd · CC BY-SA 3.0

The answer is that it depends.

I have received ICMP messages from systems with a NAT device that let internal IP addresses leak through ICMP messages.

However in order for the receiver of an ICMP message to reliably associate it with a previously sent packet, the ICMP message need to contain the triggering packet essentially as it looked originally. This means if a packet triggers an ICMP message after being modified by a NAT, the NAT has to reverse the modifications inside the ICMP payload. And some NATs get this right.

There are more subtle aspects to notice. When a NAT modify IP addresses it also has to modify checksums inside the packet. However the ICMP payload is usually a truncated IP packet, thus transport layer checksums cannot be verified. For that reason they are rarely used, and leaving checksums inside ICMP payloads unmodified won't cause breakage. However this does cause checksums to be modified in one direction and not the other. That way a little bit of information about internal IP addresses can leak.

These leaks can be considered security vulnerabilities. This is just one kind of leaks a NAT can cause. More serious leaks are also possible including the possibility of sending packet fragments to another host than the intended recipient. Those are some of the reasons NATs are not a great idea. Replacing the NAT with a firewall without NAT will provide overall better security. But that of course requires more IP addresses.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。