(译文)Securing Layer 2 Technologies | 二层网络安全技术

VLAN and Trunking Fundamentals | VLAN和Trunk的原理

Automatic negotiation to determine whether a port will be an access port or a trunk port is risky because an attacker could potentially negotiate a trunk with a switch; then the attacker could directly access any available VLANs simply by illegally tagging the traffic directly from his PC (VLAN Hopping).
与交换机自动协商出一个端口是采用access还是trunk模式的这种行为是非常危险的。因为据此攻击者也很有可能与交换机协商出trunk,并通过伪造报文直通交换机上的其他VLAN(VLAN跳跃攻击)。

Common Layer 2 Threats and How to Mitigate Them | 常见的2层威胁及治理办法

Best practice: | 最佳实践:

  • Select an unused VLAN (other than VLAN 1) and use that for the native VLAN for all your trunks.

  • Avoid using VLAN 1 anywhere, because it’s default

  • Administratively configure access ports as access ports so that users cannot negotiate a trunk and disable the negotiation of trunking (DTP) (switchport nonegotiate)

  • Limit the number of MAC addresses learned on a given port (port security feature)

  • Use BPDU Guard and Root Guard features for STP

  • Turn off CDP on ports facing untrusted or networks that do not require CDP for anything positive.

  • Shut down all unused ports.

  • 选择(除1以外)闲置的VLAN作为所有trunk接口的本征VLAN

  • 避免任意使用默认的VLAN 1

  • 将Access的端口配置成access模式,避免终端协商成trunk模式;关闭trunking协商(DTP)功能(交换机端口协商

  • 使用端口安全功能限制端口上可习得的MAC地址数量

  • 为STP开启BPDU保护和根保护功能

  • 关闭连接着不可信或者明显不需要CDP(Cisco Discovery Protocol)功能的网络的端口上的CDP功能。

  • 关闭未使用的端口

Toolkit for L2 Security | 二层安全工具箱

  • Port security: Limits the number of MAC addresses to be learned on an access switch port.

  • BPDU Guard: When you enable BPDU Guard, a switch port that was forwarding stops and disables the port if a BPDU is seen inbound on the port. A user should never be generating legitimate BPDUs. (interface# spanning-tree bpduguard enable)

  • Root Guard: Controls which port are not allowed to become root ports to remote root switches.

  • Dynamic ARP Inspection: Prevents spoofing of L2 information by hosts

  • IP Source Guard: Prevents spoofing of L3 information by hosts

  • 802.1X: Authenticates useres before allowing their data frames into the network.

  • DHCP snooping: Prevent rogue DHCP servers from impacting the network

  • Storm control: Limits the amount of broadcast or multicast traffic flowing through the switch

  • Access control list: Traffic control to enforce policy.

  • 端口安全:限制交换机端口上能够学习到的MAC地址数量

  • BPDU保护:当启用BPDU保护后,端口上一旦出现BPUD报文,交换机将停止转发该报文,并禁能该端口。用户本应禁止发出任何合法的BPDU报文

  • 根保护:控制哪些端口不能成为远端交换机的根端口。

  • 动态ARP检测:防止主机伪造L2信息

  • IP源保护:防止主机伪造L3信息

  • 802.1X:在用户向网络注入报文前需要鉴权

  • 防DHCP欺诈:防止伪造的DHCP服务器攻击网络

  • 风暴控制:限制交换机上的广播和多播流量

  • 访问控制表:根据策略控制流量

Port security | 端口安全

A typical user uses just a single MAC (except virtual machines / virtual switches/IP phone). An attacker could send thousands of frames to the network with different bogus MAC addresses, this way trying to exhaust the limits of the dynamic MAC address table on the switch, which might cause the switch to forward all frames to all ports within a VLAN so the attacker can sniff all packets. This is called CAM table overflow attack.
一般用户仅仅使用一个MAC地址(虚拟机、虚拟交换机、IP电话除外)。攻击者可以尝试通过发送成千上万拥有不同MAC地址的报文耗尽交换机上的MAC地址表;这将导致交换机会把报文发送至同一个VLAN下的所有交换机端口,攻击者便可嗅探网络中的所有报文。这被称为CAM表溢出攻击

You can use port security to limit the number of MAC addresses that the switchport can learn:
可以通过端口安全功能限制交换机端口上可以习得的MAC地址数量:

#interface Fa0/1
(int)#switchport port-security
! The default value is 1, which is not visible, but we can increase it:
(int)#switchport port-security maximum 5
! Violation action:
! - protect: Do not learn MACs above 5, and denies frames which MAC is not learned
! - restrict: Same as protect, but increases the SecurityViolation counter
! - shutdown: Puts the interface to err-disabled state and sends SNMP trap
(int)#switchport port-security violation protect</pre>

You can verify the port security settings with the *show port-security interface <interface>* or *show port-security* command.
通过命令*show port-security interface <interface>**show port-security* 验证端口安全设置。

DHCP Snooping | DHCP侦听

DHCP Snooping acts like a firewall between untrusted hosts and trusted DHCP servers:
DHCP侦听充当了不可信主机与可信DHCP服务器之间的防火墙:

  • Validates DHCP messages received from untrusted sources and filters out invalid messages
  • Rate-limits DHCP traffic from trusted and untrusted sources
  • Builds and maintains the DHCP snooping binding database, which contains information about untrusted hosts with leased IP addresses
  • Utilizes the DHCP snooping binding database to validate subsequent requests from untrusted hosts
  • 验证从不可信源接收到的DHCP消息,滤除非法消息
  • 限制可信源与不可信源之间的DHCP通信速率
  • 建立并维护包含了不可信主机及其IP绑定关系的DHCP侦听数据库
  • 根据上述建立的数据库验证不可信主机后续发出的请求

DHCP Snooping is enabled on per-VLAN basis. By default it is inactive for all VLANS.
DHCP侦听在每个VLAN上都被启用。默认使针对所有VLAN都生效的。

#ip dhcp snooping
#ip dhcp snooping vlan 10
#interface fa0/1
(int)#ip dhcp snooping trust
! Configure the DHCP snooping database agent to store the bindings
#ip dhcp snooping database tftp://1.1.1.1/directory/file

Dynamic ARP Inspection | 动态ARP检查

ARP maps the MAC address to an IP address. When a device would like to use L3 communication, first it sends an ARP message to find out what destination MAC address should it use for the L2 header. This broadcast message is received by all devices in the LAN segment and the device that has the IP address will reply with it’s own MAC address.
ARP映射了IP地址和MAC地址。设备在进行三层通信之前,首先需要发送ARP消息探测用于二层头部的目的MAC地址。同一广播域的所有设备都将接收到这个广播请求,拥有对应IP地址的设备将使用自身的ARP地址回复该请求。

A host can send gratuitous reply even if it did not receive an ARP request. This can be used for ARP cache poisoning or ARP spoofing attacks.
主机即使没有收到任何ARP请求,也可以发出免费的ARP回复。这可以用于ARP缓存投毒或ARP嗅探攻击。

In the above example when Host A want to send traffic to Host B it will first send an ARP request, because it does not know Host B’s MAC. Host C however can reply with its own MAC address, so the switch will associate the IP address of Host B with the MAC address of Host C in its MAC table. This means that all traffic from Host A will flow through Host C and Host C will forward it to Host B since it knows the real MAC. Man in the middle attack.
在上述示例中,当主机A向主机B发送数据之前,由于不知道主机B的MAC地址,首先需要发送ARP请求。
然而主机C可以使用自己的MAC地址回复主机A发出的ARP请求。交换机的MAC表中,主机B的IP被映射成主机C的MAC地址。如果主机C知道主机B的正确MAC地址,那么所有来自主机A的报文都将通过主机C中转后发送给主机B。这就是中间人攻击。

Dynamic ARP inspection intercepts, logs and discards ARP packets with invalid IP-to MAC bindings. DAI determines the validity of ARP packets based on valid IP-to-MAC binding stored in the DHCP snooping binding database.
动态ARP检测将拦截、记录、丢弃无效IP-MAC绑定关系的ARP报文。DAI根据DHCP侦听数据库和存储的有效IP-MAC绑定关系决定ARP报文的合法与否。

If the ARP packet is received on a trusted interface, the switch forwards the packet without any checks. On untrusted interfaces, the switch forwards the packet only if it is valid.
可信端口上收到的ARP报文,交换机将无条件转发。不可信端口上,交换机只转发合法的ARP报文。

译自:https://badlyconnected.wordpress.com/2018/10/09/securing-layer-2-technologies/

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 215,463评论 6 497
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,868评论 3 391
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 161,213评论 0 351
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,666评论 1 290
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,759评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,725评论 1 294
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,716评论 3 415
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,484评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,928评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,233评论 2 331
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,393评论 1 345
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,073评论 5 340
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,718评论 3 324
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,308评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,538评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,338评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,260评论 2 352

推荐阅读更多精彩内容