Layer 2 Security · Topic 2 of 4
Port Security with MAC Limiting, DHCP Snooping, DAI and IP Source Guard
Learn Junos port security: MAC limiting and packet actions, DHCP snooping, dynamic ARP inspection, IP source guard, trusted ports and how to verify them.
- 5 min
- MAC limiting uses
interface-mac-limitwith apacket-action:drop,drop-and-log,log,shutdownornone. - DHCP snooping builds a binding table and only accepts server messages on trusted ports.
- DAI checks ARP packets against the binding table and stops ARP spoofing.
What it is
Port security is a group of features that control which devices may use an access port and what addresses they may claim. They protect against MAC flooding, rogue DHCP servers, ARP spoofing and address forgery.
| Feature | Protects against | What it checks |
|---|---|---|
| MAC limiting | MAC flooding, unauthorized devices | Number of MAC addresses learned on a port |
| DHCP snooping | Rogue DHCP servers, address starvation | DHCP messages; builds a binding table |
| Dynamic ARP inspection (DAI) | ARP spoofing and poisoning | ARP packets against the binding table |
| IP source guard | IP address spoofing | Source IP and MAC against the binding table |
DAI and IP source guard both depend on the DHCP snooping binding table. They do not work without DHCP snooping on the VLAN.
How it works
MAC limiting
A MAC limit caps how many source addresses the switch learns on a port. An attacker who floods the switch with fake source addresses fills the MAC table, and the switch then floods traffic like a hub. The limit stops this. It also stops a user from attaching an unauthorized hub or switch behind a port.
user@switch# set switch-options interface ge-0/0/1 interface-mac-limit 3 packet-action drop
When the limit is reached, the switch applies the packet action to frames from additional addresses.
| Action | Effect |
|---|---|
drop | Drop frames with new addresses, do not learn them |
drop-and-log | Drop and write a system log message |
log | Write a system log message about the violation |
shutdown | Disable the port |
none | No action is taken |
Addresses learned earlier stay in the table and keep working. Older non-ELS software configured the same idea with mac-limit and action under ethernet-switching-options secure-access-port.
DHCP snooping
DHCP snooping classifies ports as trusted or untrusted. DHCP server messages, such as offer and acknowledgment, are only accepted on trusted ports. A rogue server on an untrusted port cannot hand out addresses.
The switch also listens to the DHCP exchange and builds a binding table with the client MAC address, IP address, VLAN, port and lease time.
user@switch# set vlans SALES forwarding-options dhcp-security
user@switch# set vlans SALES forwarding-options dhcp-security group SERVERS overrides trusted
user@switch# set vlans SALES forwarding-options dhcp-security group SERVERS interface ge-0/0/24.0
Snooping is enabled for the VLAN. On ELS switches, access ports are untrusted and trunk ports are trusted by default. An access port toward the real DHCP server is made trusted by placing it in a group that has overrides trusted.
user@switch> show dhcp-security binding
This displays the bindings the switch learned.
Dynamic ARP inspection
ARP has no authentication, so a host can claim another host's IP address. In ARP spoofing, an attacker sends false ARP replies to redirect traffic. DAI checks each ARP packet on an untrusted port against the DHCP snooping binding table. If the IP and MAC pair in the ARP packet does not match a binding, the packet is dropped.
user@switch# set vlans SALES forwarding-options dhcp-security arp-inspection
ARP packets that arrive on trusted ports are not checked.
IP source guard
IP source guard protects against hosts that use an IP address they were not given. The switch checks the source IP address and MAC address of each packet on an untrusted port against the binding table. A packet that does not match is dropped.
user@switch# set vlans SALES forwarding-options dhcp-security ip-source-guard
A host with a static IP address has no DHCP binding, so DAI and IP source guard drop its traffic unless you add a static binding for it.
Monitoring and troubleshooting
| Symptom | Likely cause |
|---|---|
| New devices cannot connect, old ones work | MAC limit reached with action drop |
| Port disabled after a new device appears | MAC limit action shutdown |
| Clients get no address | The access port toward the DHCP server is not trusted, so snooping drops its replies |
| Host with static IP is silent | No binding for it with DAI or IP source guard on |
| Binding table empty | Snooping not enabled on the VLAN, or clients have not renewed since |
show ethernet-switching table shows learned addresses per port, which you compare against the MAC limit. show dhcp-security binding shows the binding table.
After turning on DHCP snooping, existing clients have no bindings until they renew. If DAI or IP source guard is turned on at the same time, those clients can lose connectivity. Enable snooping first and let leases renew.
Forgetting to trust an access port toward the DHCP server is the classic fault. Offers from the server arrive on an untrusted port and are discarded. Trunk uplinks are already trusted by default.
Common mistakes
Enabling DAI or IP source guard without DHCP snooping. They have no binding table to check against.
Not trusting server ports. DHCP offers are dropped, and no client gets an address.
Setting a MAC limit that is too low. A phone and a PC on one port are two addresses. A limit of 1 blocks one of them.
Forgetting static hosts. Servers and printers with fixed IP addresses need static bindings.
What to remember for the exam
- MAC limiting uses
interface-mac-limitwith apacket-action:drop,drop-and-log,log,shutdownornone. - DHCP snooping builds a binding table and only accepts server messages on trusted ports.
- DAI checks ARP packets against the binding table and stops ARP spoofing.
- IP source guard checks source IP and MAC against the binding table and stops address spoofing.
- DAI and IP source guard need DHCP snooping on the same VLAN.
- ELS configuration is under
vlans NAME forwarding-options dhcp-security. show dhcp-security bindingshows the binding table.
Check yourself
Which feature stops an attacker from filling the MAC table with fake source addresses?
MAC limiting, which caps the number of learned addresses on a port.
DAI is enabled but the VLAN has no DHCP snooping. What is missing?
The binding table that DAI compares ARP packets against.
Why do DHCP clients get no address after snooping is enabled?
The port toward the DHCP server is probably not trusted, so the server's offers are dropped.
Topic 2 of 4 in Layer 2 Security
Test yourself on Layer 2 Security
The full Juniper JNCIS-ENT JN0-352 question bank has 846 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.