Chapter 6. Masquerading and Source Network Address Translation

本文探讨了源网络地址转换(SNAT)与伪装的概念及其在保护内部网络发起连接或流量中的应用。文中还讨论了SNAT与伪装之间的区别以及它们在处理入站流量时可能遇到的问题。

Chapter 6. Masquerading and Source Network Address Translation

Table of Contents

6.1. Concepts of Source NAT
6.1.1. Differences Between SNAT and Masquerading6.1.2. Double SNAT/Masquerading
6.2. Issues with SNAT/Masquerading and Inbound Traffic6.3. Where Masquerading and SNAT Break

Commonly known under a variety of names, SNAT, masquerading or Many-To-One NAT can be part of a solution to protect

Masquerading for connections or traffic initiated from inside a network. Consider reading Chapter 5, Network Address Translation (NAT) for details on handling inbound traffic or connections.

Masquerading has been supported under the linux kernel since before kernel 2.0. The technique of masquerading

CPU Directed Address Learning and Purging Sometimes it is required to prevent automatic learning from occurring on a port and have a CPU direct the learning instead. The device supports CPU directed learning on a per port basis by setting the port’s LockedPort bit to a one (Port offset 0x0B). When a port is ‘Locked’ all frames received with an SA not found in the address database cause an SA Miss ATU Violation as long as learning is enabled on the port (i.e., the port’s PAV, offset 0x0B, is non-zero). The SA Miss ATU Violation can be set to generate a hardware interrupt—see the ATUProbIntEn bit of the Switch Global Control register (Global 1 offset 0x04). One ATU Violation per port is held in the ATU. Once a violation is captured all subsequent violations are ignored until the first one is serviced by the CPU. Alternatively, frames with unknown SA's can be mirrored to the CPU (using a Policy Mirror - Section 2.1.3). This is done by setting the Mirror SA Miss bit to a one (Port offset 0x0D). The port needs to still be locked (LockedPort = 1) to stop automatic address learning. In this mode the SA Miss interrupts from the ATU can be ignored or masked as the CPU will get the frames instead. The CPU can retrieve the source MAC address and the source port information of the SA Miss Violation by issuing an ATU Get/Clear Violation Data ATUOp (Section 6.3.6). The CPU then decides if the address should be placed into the address database or not. If it should be, the CPU issues a Load ATUOp (Section 6.3.3). If the CPU loads the new address as ‘non-static’, the entry stays in the address database until it ages out. Its age time is determined by the loaded EntryState value 2 . Normally, addresses on Locked ports do not have their age time refreshed, but they can if the port’s RefreshLocked bit is set to a one (Port offset 0x0B). In this case, addresses already present in the address database will be automatically refreshed (i.e., get their EntryState set to 0x7) as long as the association on the address is not changing (i.e., as long as it is not a station move). Learn2All message frames are generated on these automatic refreshes if the Learn2All bit is set to a one (Global 1 offset 0x0A). Learn2All is used to automatically learn addresses cross-chip in cascaded or multi-chip applications. The CPU can receive interrupts from aging addresses when configured for CPU Directed Learning (i.e., the port's LockedPort in Port offset 0x0B = 1) as follows: 1. The EntryState field is described in Section 6.3.1. 2. The Age Time (Global 1, offset 0x0A) determines the age time as well. See Section 1.2.5. MARVELL CONFIDENTIAL - UNAUTHORIZED DISTRIBUTION OR USE STRICTLY PROHIBITED jl62zm96mul7odd5g98n2ka4wa6e951m5p-kgszdlt5 *TP-Link Technologies Co., Ltd. * UNDER NDA# 58686MARVELL CONFIDENTIAL, UNDER NDA# 58686 jl62zm96mul7odd5g98n2ka4wa6e951m5p-kgszdlt5 *TP-Link Technologies Co., Ltd. jl62zm96mul7odd5g98n2ka4wa6e951m5p-kgszdlt5 *TP-Link Technologies Co., Ltd. MARVELL CONFIDENTIAL, UNDER NDA# 58686 Switch Core Functional Description Basic Switch Operation Copyright © 2018 Marvell CONFIDENTIAL Doc. No. MV-S111519-00 Rev. -- August 22, 2018 Document Classification: Proprietary Information Page 47 1.2.5 Automatic Address Aging The address aging process is used to ensure that if a node is disconnected from the network seg- ment, or if it becomes inactive, its entry is removed in a timely manner from the address database. Aging makes room for new active addresses. An address is removed from the database after a pro- grammable amount of time from the last time the address appeared in an ingressing frame’s Source Address. This programmable time is determined by the Age Time bits in the ATU Control register (Global 1 offset 0x0A). The device runs the address aging process continuously (unless disabled by setting the AgeTime field to zeros). Aging is accomplished by a periodic sweep of the address database. The speed of these sweeps determines the aging time. On each aging sweep of the database, the ATU reads each valid entry and updates its age time by decrementing its EntryState field 1 (as long as the entry is not static – see Section 6.3.1). When the EntryState field reaches zero, the entry is considered invalid and purged from the database. The EntryState field will not decrement past 0x1 (i.e., it will not be automatically purged) if the port’s HoldAt1 bit is set (Port offset 0x0B). HoldAt1 is intended to be used with CPU directed Address Learning (Section 1.2.6). A new or just refreshed unicast MAC address has an EntryState value of 0x7 (see Section 1.2.3). A purged or invalid entry has an EntryState value of 0x0. The values from 0x6 to 0x1 indicate the Age time on the unicast MAC address with 0x1 being the oldest. This scheme results in seven age states on an entry allowing the Address Learning’s least recently used replacement process (Section 1.2.3) to be more precise. An address is purged from the database within 1/7th of the programmed AgeTime value making the address’s lifetime interval in the database more accurate as well. 1.2.6 CPU Directed Address Learning and Purging Sometimes it is required to prevent automatic learning from occurring on a port and have a CPU direct the learning instead. The device supports CPU directed learning on a per port basis by setting the port’s LockedPort bit to a one (Port offset 0x0B). When a port is ‘Locked’ all frames received with an SA not found in the address database cause an SA Miss ATU Violation as long as learning is enabled on the port (i.e., the port’s PAV, offset 0x0B, is non-zero). The SA Miss ATU Violation can be set to generate a hardware interrupt—see the ATUProbIntEn bit of the Switch Global Control register (Global 1 offset 0x04). One ATU Violation per port is held in the ATU. Once a violation is captured all subsequent violations are ignored until the first one is serviced by the CPU. Alternatively, frames with unknown SA's can be mirrored to the CPU (using a Policy Mirror - Section 2.1.3). This is done by setting the Mirror SA Miss bit to a one (Port offset 0x0D). The port needs to still be locked (LockedPort = 1) to stop automatic address learning. In this mode the SA Miss interrupts from the ATU can be ignored or masked as the CPU will get the frames instead. The CPU can retrieve the source MAC address and the source port information of the SA Miss Violation by issuing an ATU Get/Clear Violation Data ATUOp (Section 6.3.6). The CPU then decides if the address should be placed into the address database or not. If it should be, the CPU issues a Load ATUOp (Section 6.3.3). If the CPU loads the new address as ‘non-static’, the entry stays in the address database until it ages out. Its age time is determined by the loaded EntryState value 2 . Normally, addresses on Locked ports do not have their age time refreshed, but they can if the port’s RefreshLocked bit is set to a one (Port offset 0x0B). In this case, addresses already present in the address database will be automatically refreshed (i.e., get their EntryState set to 0x7) as long as the association on the address is not changing (i.e., as long as it is not a station move). Learn2All message frames are generated on these automatic refreshes if the Learn2All bit is set to a one (Global 1 offset 0x0A). Learn2All is used to automatically learn addresses cross-chip in cascaded or multi-chip applications. The CPU can receive interrupts from aging addresses when configured for CPU Directed Learning (i.e., the port's LockedPort in Port offset 0x0B = 1) as follows: 1. The EntryState field is described in Section 6.3.1. 2. The Age Time (Global 1, offset 0x0A) determines the age time as well. See Section 1.2.5. MARVELL CONFIDENTIAL - UNAUTHORIZED DISTRIBUTION OR USE STRICTLY PROHIBITED jl62zm96mul7odd5g98n2ka4wa6e951m5p-kgszdlt5 *TP-Link Technologies Co., Ltd. * UNDER NDA# 58686 MARVELL 机密,根据 NDA# 58686 jl62zm96mul7odd5g98n2ka4wa6e951m5p-kgszdlt5 *TP-Link Technologies Co., Ltd. jl62zm96mul7odd5g98n2ka4wa6e951m5p-kgszdlt5 *TP-Link Technologies Co., Ltd. MARVELL 机密,根据 NDA# 58686 交换机核心功能说明 基本开关作 版权所有 © 2018 Marvell 机要 文档编号 MV-S111519-00 修订版 -- 八月 22, 2018 文档分类:专有信息 第 47 页 1.2.5 自动地址帐龄 地址老化过程用于确保如果节点与网段断开连接,或者当它变得不活动时,它会及时从地址数据库中删除其条目。老化为新的活跃地址腾出了空间。地址在上次出现在入口帧的源地址中的可编程时间后,将从数据库中删除地址。该可编程时间由 ATU 控制寄存器中的年龄时间位决定(全局 1 失调 0x0A)。 设备连续运行地址老化过程(除非通过将 AgeTime 字段设置为零来禁用)。老化是通过定期扫描地址数据库来完成的。这些扫描的速度决定了老化时间。在数据库的每次老化扫描中,ATU 都会读取每个有效条目,并通过递减其 EntryState 字段来更新其年龄时间(只要条目不是静态的 - 请参阅第 6.3.1 节)。当 EntryState 字段达到零时,该条目将被视为无效并从数据库中清除。如果设置了端口的 HoldAt1 位(端口偏移量 0x0B),则 EntryState 字段将不会递减超过 0x1(即不会自动清除)。HoldAt1 旨在与 CPU 定向地址学习一起使用(第 1.2.6 节)。 新的或刚刚刷新的单播 MAC 地址的 EntryState 值为 0x7(参见第 1.2.3 节)。清除或无效条目的 EntryState 值为 0x0。从 0x6 到 0x1 的值表示单播 MAC 地址上的年龄时间,其中 0x1 是最旧的。该方案导致条目上有七个年龄状态,从而允许更精确地显示地址学习最近使用最少的替换过程(第 1.2.3 节)。在编程的 1/7 范围内从数据库中清除地址 AgeTime 值也使地址在数据库中的生存期间隔更加准确。 1.2.6 CPU 定向地址学习和清除 有时需要防止在端口上发生自动学习,并让 CPU 指导学习。该器件通过将端口的 LockedPort 位设置为 1(端口偏移量 0x0B)来支持每个端口的 CPU 定向学习。当端口处于“锁定”状态时,只要在端口上启用了学习(即端口的 PAV,偏移量 0x0B,非零),所有在地址数据库中未找到 SA 接收的帧都会导致 SA 未命中 ATU 冲突。可以将 SA Miss ATU Violation 设置为生成硬件中断 - 请参阅交换机全局控制寄存器的 ATUProbIntEn 位(全局 1 偏移量 0x04)。每个端口在 ATU 中保留一次 ATU 违规行为。捕获违规后,将忽略所有后续违规,直到 CPU 处理第一个违规。 或者,可以将具有未知 SA 的帧镜像到 CPU(使用策略镜像第 2.1.3 节)。这是通过将镜像 SA 未命中位设置为 1(端口偏移 0x0D)来完成的。端口仍需要锁定(LockedPort = 1)以停止自动地址学习。在此模式下,可以忽略或屏蔽来自 ATU 的 SA 未命中中断,因为 CPU 将获取帧。 CPU 可以通过发出 ATU Get/Clear Violation Data ATUOp(第 6.3.6 节)来检索 SA Miss Violation 的源 MAC 地址和源端口信息。然后 CPU 决定是否应将地址放入地址数据库中。如果应该是,CPU 会发出 Load ATUOp(第 6.3.3 节)。 如果 CPU 将新地址加载为“非静态”,则该条目将保留在地址数据库中,直到它过期。其年龄时间由加载的 EntryState 值确定。通常,锁定端口上的地址不会刷新其年龄时间,但如果端口的 RefreshLocked 位设置为 1(端口偏移量 0x0B),则可以刷新其年龄时间。在这种情况下,地址数据库中已经存在的地址将自动刷新(即,将其 EntryState 设置为 0x7),只要地址上的关联没有改变(即,只要它不是站点移动)。如果 Learn2All 位设置为 1(全局 1 偏移量 0x0A),则在这些自动刷新时生成 Learn2All 消息帧。 Learn2All 用于在级联或多芯片应用中自动学习跨芯片地址。 当配置为 CPU 定向学习(即端口的 LockedPort in Port 偏移量 0x0B = 1)时,CPU 可以接收来自老化地址的中断,如下所示: 1. EntryState 字段在第 6.3.1 节中进行了描述。 2. 年龄时间(全局 1,偏移量 0x0A)也决定了年龄时间。参见第 1.2.5 节。 MARVELL 机密 - 严禁未经授权分发或使用 jl62zm96mul7odd5g98n2ka4wa6e951m5p-kgszdlt5 *TP-Link Technologies Co., Ltd. * 根据 NDA# 58686 MARVELL CONFIDENTIAL, UNDER NDA# 58686 jl62zm96mul7odd5g98n2ka4wa6e951m5p-kgszdlt5 *TP-Link Technologies Co., Ltd. jl62zm96mul7odd5g98n2ka4wa6e951m5p-kgszdlt5 *TP-Link Technologies Co., Ltd. MARVELL CONFIDENTIAL, UNDER NDA# 58686 Doc. No. MV-S111519-00 Rev. -- CONFIDENTIAL Copyright © 2018 Marvell Page 48 Document Classification: Proprietary Information August 22, 2018 88E6393X/88E6193X/88E6191X Switch Functional Specification  When frames are received that contain an SA in the address database the CPU will receive an ATU Miss Violation interrupt if the EntryState found in the address database on the ingressing frame’s SA is less than 0x4 (and the port’s RefreshLocked bit is cleared to zero). This allows the CPU to refresh the aging entry's EntryState before the entry completely ages out (with an EntryState less than 0x4 the entry is more than ½ aged out.  Regardless if frames are being received or not, if the port’s IntOnAgeOut (interrupt on age out) is enabled, the CPU will receive an Age Out Violation whenever any address associated with the port 1 is aging out (i.e., the entry has an EntryState of 0x1 when aging starts to process the entry). The entry will then either be aged out of the address database (i.e., its EntryState will be cleared to 0x0), or its EntryState value will be held at 0x1 if the port’s HoldAt1 bit is set (Port offset 0x0B). The Hold at 1 feature requires that the CPU purge the entry from the address database, which gives the CPU can control over when and where addresses are removed. In either case, the CPU is informed that a specific MAC address has not been used for the configured Age Time (Global 1 offset 0x0A). If the CPU loads the new address as ‘static’, the entry stays in the address database until the CPU purges it. In this case, the CPU receives no interrupts from this address as long as the address is never used as an SA on a port other than the original source port. If the MAC address is used on a different source port, the CPU can receive an ATU Member Violation interrupt if the IgnoreWrongData bit (Port offset 0x0B) is cleared on the port where the frame just entered the switch. This interrupt may indicate that a station move just occurred or that an end station is masquerading by using another station’s address 总结
最新发布
08-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值