Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Example: Configuring DHCP Snooping, DAI , and MAC Limiting on a Switch with Access to a DHCP Server Through a Second Switch

You can configure DHCP snooping, dynamic ARP inspection (DAI), and MAC limiting on the access interfaces of a switch to protect the switch and the Ethernet LAN against address spoofing and Layer 2 denial-of-service (DoS) attacks. To obtain the basic settings for these features, you can use the switch's default configuration for port security, configure the MAC limit, and enable DHCP snooping and DAI on a VLAN. You can configure these features when the DHCP server is connected to a switch that is different from the one to which the DHCP clients (network devices) are connected.

This example describes how to configure port security features on a switch whose hosts obtain IP addresses and lease times from a DHCP server connected to a second switch:

Requirements

This example uses the following hardware and software components:

  • One EX Series switch or QFX3500 switch—Switch 1 in this example.
  • An additional EX Series switch or QFX3500 switch—Switch 2 in this example. You do not configure port security on this second switch.
  • Junos OS Release 9.0 or later for EX Series switches or Junos OS Release 12.1 or later for the QFX Series.
  • A DHCP server connected to Switch 2. You use the server to provide IP addresses to network devices connected to Switch 1.
  • At least two network devices (hosts) that you connect to access interfaces on Switch 1. These devices are DHCP clients.

Before you configure DHCP snooping, DAI, and MAC limiting port security features, be sure you have:

Overview and Topology

Ethernet LANs are vulnerable to address spoofing and DoS attacks on network devices. To protect the devices from such attacks, you can configure:

  • DHCP snooping to validate DHCP server messages
  • DAI to protect against ARP spoofing
  • MAC limiting to constrain the number of MAC addresses the switch adds to its MAC address cache

This example shows how to configure these port security features on Switch 1. Switch 1 is connected to another switch (Switch 2), which is not configured with port security features. Switch 2 is connected to a DHCP server (see Figure 1.) Network devices (hosts) that are connected to Switch 1 send requests for IP addresses (these network devices are DHCP clients). Those requests are transmitted from Switch 1 to Switch 2 and then to the DHCP server connected to Switch 2. Responses to the requests are transmitted along the reverse path of the one followed by the requests.

The setup for this example includes the VLAN employee-vlan on both switches.

Figure 1 shows the network topology for the example.

Figure 1: Network Topology for Port Security Setup with Two Switches on the Same VLAN

Network Topology for Port Security Setup with Two Switches on the
Same VLAN

The components of the topology for this example are shown in Table 1.

Table 1: Components of Port Security Setup on Switch 1 with a DHCP Server Connected to Switch 2

PropertiesSettings

Switch hardware

One EX Series switch or one QFX3500 switch (Switch 1), and an additional EX Series switch or QFX3500 switch (Switch 2)

VLAN name and ID

employee-vlan, tag 20

VLAN subnets

192.0.2.16/28
192.0.2.17 through 192.0.2.30
192.0.2.31 is subnet's broadcast address

Trunk interface on both switches

ge-0/0/11

Access interfaces on Switch 1

ge-0/0/1, ge-0/0/2, and ge-0/0/3

Access interface on Switch 2

ge-0/0/1

Interface for DHCP server

ge-0/0/1 on Switch 2

Switch 1 is initially configured with the default port security setup. In the default configuration on the switch:

  • Secure port access is activated on the switch.
  • The switch does not drop any packets, which is the default setting.
  • DHCP snooping and DAI are disabled on all VLANs.
  • All access interfaces are untrusted and trunk interfaces are trusted; these are the default settings.

In the configuration tasks for this example, you configure a VLAN on both switches.

In addition to configuring the VLAN, you enable DHCP snooping on Switch 1. In this example, you also enable DAI and a MAC limit of 5 on Switch 1.

Because the interface that connects Switch 2 to Switch 1 is a trunk interface, you do not need to configure this interface to be trusted. As noted above, trunk interfaces are automatically trusted, so DHCP messages coming from the DHCP server to Switch 2 and then on to Switch 1 are trusted.

Configuring a VLAN, Interfaces, and Port Security Features on Switch 1

CLI Quick Configuration

To quickly configure a VLAN, interfaces, and port security features, copy the following commands and paste them into the switch terminal window:

[edit]
set ethernet-switching-options secure-access-port interface ge-0/0/1 mac-limit 5 action drop
clear ethernet-switching table interface ge-0/0/1
set ethernet-switching-options secure-access-port vlan employee-vlan arp-inspection
set ethernet-switching-options secure-access-port vlan employee-vlan examine-dhcp
set interfaces ge-0/0/1 unit 0 family ethernet-switching vlan members 20
set interfaces ge-0/0/2 unit 0 family ethernet-switching vlan members 20
set interfaces ge-0/0/3 unit 0 family ethernet-switching vlan members 20
set interfaces ge-0/0/11 unit 0 family ethernet-switching port-mode trunk
set interfaces ge-0/0/11 unit 0 family ethernet-switching vlan members 20
set vlans employee-vlan vlan-id 20

Step-by-Step Procedure

To configure MAC limiting, a VLAN, and interfaces on Switch 1 and enable DAI and DHCP on the VLAN:

  1. Configure the VLAN employee-vlan with VLAN ID 20:
    [edit vlans]
    user@switch1# set employee-vlan vlan-id 20
  2. Configure an interface on Switch 1 as a trunk interface:
    [edit interfaces]
    user@switch1# set ge-0/0/11 unit 0 family ethernet-switching port-mode trunk
  3. Associate the VLAN with interfaces ge-0/0/1, ge-0/0/2, ge-0/0/3, and ge-0/0/11:
    [edit interfaces]
    user@switch1# set ge-0/0/1 unit 0 family ethernet-switching vlan members 20
    user@switch1# set ge-0/0/2 unit 0 family ethernet-switching vlan members 20
    user@switch1# set ge-0/0/3 unit 0 family ethernet-switching vlan members 20
    user@switch1# set ge-0/0/11 unit 0 family ethernet-switching vlan members 20
  4. Enable DHCP snooping on the VLAN:
    [edit ethernet-switching-options secure-access-port]
    user@switch1# set vlan employee-vlan examine-dhcp
  5. Enable DAI on the VLAN:
    [edit ethernet-switching-options secure-access-port]
    user@switch1# set vlan employee-vlan arp-inspection
  6. Configure a MAC limit of 5 on ge-0/0/1 and use the default action, drop (packets with new addresses are dropped if the limit is exceeded):
    [edit ethernet-switching-options secure-access-port]
    user@switch1# set interface ge-0/0/1 mac-limit 5 drop
  7. Clear the existing MAC address table entries from interface ge-0/0/1:
    user@switch1# clear ethernet-switching table interface ge-0/0/1

Results

Display the results of the configuration:

[edit]user@switch1# show
ethernet-switching-options {secure-access-port {interface ge-0/0/1.0{mac-limit 5 action drop;}vlan employee-vlan {arp-inspection;examine-dhcp;}}}
interfaces {ge-0/0/1 {unit 0 {family ethernet-switching {port-mode trunk;vlan {members 20;}}}}ge-0/0/2 {unit 0 {family ethernet-switching {vlan {members 20;}}}}ge-0/0/3 {unit 0 {family ethernet-switching {vlan {members 20;}}}}ge-0/0/11 {unit 0 {family ethernet-switching {port-mode trunk;vlan {members 20;}}}}}
vlans {employee-vlan {vlan-id 20;}}

Configuring a VLAN and Interfaces on Switch 2

To configure the VLAN and interfaces on Switch 2:

CLI Quick Configuration

To quickly configure the VLAN and interfaces on Switch 2, copy the following commands and paste them into the switch terminal window:

[edit]
set interfaces ge-0/0/1 unit 0 family ethernet-switching port-mode trunk
set interfaces ge-0/0/11 unit 0 family ethernet-switching port-mode trunk
set vlans employee-vlan vlan-id 20

Step-by-Step Procedure

To configure the VLAN and interfaces on Switch 2:

  1. Configure an interface on Switch 2 as a trunk interface:
    [edit interfaces]
    user@switch2# set ge-0/0/11 unit 0 ethernet-switching port-mode trunk
  2. Associate the VLAN with interfaces ge-0/0/1 and ge-0/0/11:
    [edit interfaces]
    user@switch2# set ge-0/0/1 unit 0 family ethernet-switching vlan members 20
    user@switch2# set ge-0/0/11 unit 0 family ethernet-switching vlan members 20

Results

Display the results of the configuration:

[edit]user@switch2# show
interfaces {ge-0/0/1 {unit 0 {family ethernet-switching {vlan {members 20;}}}}ge-0/0/11 {unit 0 {family ethernet-switching {port-mode trunk;vlan {members 20;}}}}}
vlans {employee-vlan {vlan-id 20;}}

Verification

To confirm that the configuration is working properly.

Verifying That DHCP Snooping Is Working Correctly on Switch 1

Purpose

Verify that DHCP snooping is working on Switch 1.

Action

Send some DHCP requests from network devices (here they are DHCP clients) connected to the switch.

Issue the operational mode command show dhcp snooping binding to display the DHCP snooping information when the interface through which Switch 2 sends the DHCP server replies to clients connected to Switch 1 is trusted. The server has provided the IP addresses and leases:

user@switch1> show dhcp snooping binding
DHCP Snooping Information:
MAC Address         IP Address    Lease    Type     VLAN          Interface

----------------- ---------- ----- ---- ---- ---------
00:05:85:3A:82:77 192.0.2.17 600 dynamic employee—vlan ge-0/0/1.0
00:05:85:3A:82:79 192.0.2.18 653 dynamic employee—vlan ge-0/0/1.0
00:05:85:3A:82:80 192.0.2.19 720 dynamic employee—vlan ge-0/0/1.0
00:05:85:3A:82:81 192.0.2.20 932 dynamic employee—vlan ge-0/0/1.0
00:05:85:3A:82:83 192.0.2.21 1230 dynamic employee—vlan ge-0/0/1.0
00:05:85:3A:82:90 192.0.2.20 932 dynamic employee—vlan ge-0/0/2.0
00:05:85:3A:82:91 192.0.2.21 1230 dynamic employee—vlan ge-0/0/3.0

Meaning

The output shows, for each MAC address, the assigned IP address and lease time—that is, the time, in seconds, remaining before the lease expires.

Verifying That DAI Is Working Correctly on Switch 1

Purpose

Verify that DAI is working on Switch 1.

Action

Send some ARP requests from network devices connected to the switch.

Issue the operational mode command show arp inspection statistics to display the DAI information:

user@switch1> show arp inspection statistics
ARP inspection statistics:
Interface    Packets received  ARP inspection pass  ARP inspection failed
----------   –-------------–-  -------------------  ---------------------
ge-0/0/1.0                  7                    5                      2
ge-0/0/2.0                 10                   10                      0
ge-0/0/3.0                 18                   15                      3

Meaning

The sample output shows the number of ARP packets received and inspected per interface, with a listing of how many packets passed and how many failed the inspection on each interface. The switch compares the ARP requests and replies against the entries in the DHCP snooping database. If a MAC address or IP address in the ARP packet does not match a valid entry in the database, the packet is dropped.

Verifying That MAC Limiting Is Working Correctly on Switch 1

Purpose

Verify that MAC limiting is working on Switch 1.

Action

Issue the operational mode command show ethernet-switching table to display the MAC addresses that are learned when DHCP requests are sent from hosts on ge-0/0/1:

user@switch1> show ethernet-switching table
Ethernet-switching table:  6 entries, 5 learned

VLAN MAC address Type Age Interfaces employee-vlan 00:05:85:3A:82:77 Learn 0 ge-0/0/1.0 employee-vlan 00:05:85:3A:82:79 Learn 0 ge-0/0/1.0 employee-vlan 00:05:85:3A:82:80 Learn 0 ge-0/0/1.0 employee-vlan 00:05:85:3A:82:81 Learn 0 ge-0/0/1.0 employee-vlan 00:05:85:3A:82:83 Learn 0 ge-0/0/1.0 employee-vlan * Flood - ge-0/0/1.0

Meaning

The output shows that five MAC addresses have been learned for interface ge-0/0/1, which corresponds to the MAC limit of 5 set in the configuration. The last line of the output shows that a sixth MAC address request was dropped, as indicated by the asterisk (*) in the MAC address column.

Published: 2014-07-30