Wiki DE Start in the browser

Wiki › Protocols

Switch security: port security and DHCP snooping

Fending off attacks inside your own LAN: MAC flooding, DHCP starvation and rogue DHCP servers, forged senders, and what the switch does about them.

Layer
2 (Sicherung)
Standard
RFC 7513, RFC 2131, RFC 826 …

Why the switch has to help

A firewall usually sits at the edge of the network. Anyone already inside the LAN, e.g. with a notebook on a free wall socket, reaches all devices in the same VLAN directly. Three attacks are particularly easy there:

AttackWhat happensSTRIDE
MAC floodingThousands of invented sender MACs fill the MAC table. Once it is full, the switch sends all frames to all ports and the attacker listens in.Information disclosure
DHCP starvation and rogue DHCP serverFirst empty the real server's address pool with invented requests, then hand out addresses yourself, with yourself as gateway and DNS.Tampering, spoofing
IP spoofingSend packets with someone else's sender address, e.g. to get around a firewall rule or to pin an attack on someone else.Spoofing

The switch helps against all three, because only it sees on which port a frame comes in.

Port security

At most N MAC addresses are allowed per port (e.g. 2: PC and IP phone). The switch learns the first N; it drops frames from further senders and reports the violation. MAC flooding and DHCP starvation come to nothing.

Real switches know three reactions: protect (drop silently), restrict (drop and report) and shutdown (disable the port). leyoNET works like restrict: the port stays up, the violation appears on the console and via Syslog.

Switch(config)# interface fa0/3
Switch(config-if)# switchport port-security
Switch(config-if)# switchport port-security maximum 2
Switch# show port-security

DHCP snooping

The switch distinguishes trusted ports (towards the real DHCP server or the uplink to it) from all others. It only lets replies from a DHCP server (offer, ack, nak, RFC 2131) in on trusted ports. A rogue server on an office socket cannot give anyone an address.

On the side, the switch keeps a binding table: which IP address the server gave to which MAC on which port and VLAN. The method follows the idea of SAVI for DHCP (RFC 7513).

Switch(config)# ip dhcp snooping
Switch(config)# interface gi0/1
Switch(config-if)# ip dhcp snooping trust
Switch# show ip dhcp snooping binding

IP source guard

IP source guard builds on the binding table: on the protected port only IPv4 packets with exactly the sender address that the DHCP server gave this device get through. The switch drops forged senders and manually configured addresses.

Switch(config-if)# ip verify source
Switch# show ip verify source

What these functions do not cover

  • ARP spoofing: IP source guard does not check ARP packets. Real switches have dynamic ARP inspection (DAI) for this, which compares ARP replies with the binding table. leyoNET protects on the end device here (ARP guard, see ARP and IT security: attacks and defence).
  • Who is plugged into the port: port security only counts addresses. A real login at the port (user or certificate, via a RADIUS server) is handled by IEEE 802.1X. In leyoNET only EAPOL from it appears, for the key exchange in Wi-Fi.
  • Unused sockets should be shut down (shutdown) or put into a separate VLAN without access.

Try it in leyoNET

  1. Open the exercise “Attack: Who is handing out addresses here?” and start the simulation: the PCs get addresses from the attacker.
  2. On the switch open the Protection tab: DHCP snooping on, the port to the real server trusted, port security with 2 addresses.
  3. Restart the simulation, ipconfig /renew on the PCs: now the real server answers, and the violations appear on the switch console.
  4. Exercise “Attack: who is listening in?” (MAC flooding): first let the attacker listen in, then fend it off with port security.

How to do it in leyoNET

The same text as in the app’s help (F1 key).

DHCP snooping, port security and IP Source Guard

Three protective functions on the switch, in the device window under Protection or on the command line.

DHCP snooping (following RFC 7513): Only on trusted ports may a DHCP server answer (Offer, Ack, Nak). Trusted is the port to the real DHCP server or the uplink towards it. Client requests only pass if the client MAC in the DHCP packet is the sender MAC. This way a rogue DHCP server in the network cannot give anyone an address with a wrong gateway.

Port security: at most this many MAC addresses on a port (e.g. 2). The switch drops further senders and reports it (“restrict”). This prevents a device with made-up MAC addresses from using up the DHCP server's address pool (DHCP starvation) or flooding the switch's MAC table (MAC flooding: once it is full, the switch sends frames to all ports and the attacker reads along).

IP Source Guard (needs DHCP snooping): the switch remembers which address the DHCP server gave which device (binding with MAC, port and VLAN). On a protected port it only lets through IPv4 packets with exactly this sender address. Spoofed senders and manually set addresses are dropped. It does not check ARP.

Command line:

  • ip dhcp snooping
  • on the port: ip dhcp snooping trust
  • on the port: switchport port-security maximum 2
  • on the port: ip verify source
  • show ip dhcp snooping, show ip dhcp snooping binding, show ip verify source, show port-security

Violations appear in the switch console and, with a management address, on the Syslog server. To try it: attack “Rogue DHCP server” under Security scenarios.

Security scenarios

Attacks to watch and to fend off. Everything runs only in the simulation, no real packet is ever sent.

Attacker as a device: Drag the Attacker from the shop (end devices) onto the canvas, cable it, give it an address and choose the attack on the right. It starts shortly after the simulation.

  • ARP spoofing (Spoofing): pretends to be the gateway. Defence: ARP guard on the end devices
  • SYN flood (Denial of Service): fills the web server's queue. Defence: SYN cookies or a rule in the Firewall
  • Port scan (Information Disclosure): looks for open ports. Defence: remove superfluous services and Port forwarding
  • Guess SSH password (Elevation of Privilege): tries common passwords. Defence: strong password, block SSH from outside
  • Rogue DHCP server (Tampering): uses up the real server's pool with made-up MAC addresses and then hands out itself as gateway and DNS. Defence: DHCP snooping, port security and IP Source Guard (DHCP snooping and port security)
  • MAC flooding (Information Disclosure): fills the switch's MAC table with made-up senders; the switch then sends other people's traffic to all ports and the attacker reads along. Defence: port security (DHCP snooping, port security and IP Source Guard)

Proof (Repudiation): With Syslog, guards, switches and routers report their events to a syslog server. This shows later what happened when and from where.

Guard and protection: Desktop of PC, notebook or server → Security. It shows what is suspicious, and there you switch on the protection.

In class: The teacher can start an attack on one or all sessions (Class in the lesson).

Physical incidents (class): The teacher can also trigger a fire, a power surge (lightning strike), a theft or Bad USB, for everyone, per seat or at the top of a seat's view, and chooses how many devices it hits at most. While editing a session, the result shows at once. Unlike the attacks above, this takes real effect: fire, surge and theft remove randomly chosen devices including their cables (with fire, devices standing next to each other), Bad USB resets a PC, notebook or server to factory settings. A notice at the top says what happened and what protects against it. Replacements are in the shop; a Snapshots backup makes it quicker. The incident cannot be undone.

STRIDE sorts threats: Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, Elevation of Privilege.

Practise

  • ★★★★☆ Attack: Who is handing out addresses here? · 4 goals · Worksheet (German)
  • ★★★☆☆ Attack: who is listening in? · 4 goals · Worksheet (German)
  • ★★★☆☆ Attack: Who pretends to be the gateway? · 4 goals · Worksheet (German)

In leyoNET under Tools → Exercise catalogue. Every exercise checks itself.

Standards

  • RFC 7513 – Source Address Validation Solution for DHCP (SAVI-DHCP)
  • RFC 2131 – Dynamic Host Configuration Protocol
  • RFC 826 – An Ethernet Address Resolution Protocol
  • IEEE 802.1X – Port-Based Network Access Control (current edition: IEEE 802.1X-2020)

Read on

Found a mistake or have an idea? Source of this page on GitHub.