cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
372
Views
0
Helpful
3
Replies

Automation of IP DHCP Snooping configuration - Where is the real DHCP

dal
Level 3
Level 3

Hi.

I wanted to create a python script for automating configuration of DHCP Snooping on our switches.

But; All switches are not configured equally, and the uplink port towards the real DHCP server (the switchport where ip dhcp snooping trust needs to be configured) varies from switch to switch.

So how can we determine on what switchport traffic to the DHCP server leaves the switch?

Earlier it was possible to ping the DHCP  server from the switch, and an entry would appear in the arp table of the switch, but this is no longer the case

Use the gateway address of the management ip maybe?

Any tips ?

Thanks

3 Replies 3

M02@rt37
VIP
VIP

Hello @dal 

One approach is to leverage the gateway address of the management IP on the switch.

If the management IP is in the same subnet as the DHCP server, the gateway will be the next hop for traffic to the DHCP server. By checking the routing table for the gateway, you can identify the interface leading to it. From there, use the MAC address table to map the gateway's MAC address to the physical switchport. This is straightforward way to determine the uplink port.

Other things is to trace the path of a DHCP request. Enable DHCP snooping globally on the switch without configuring any trusted ports. Then, generate a test DHCP request from a client in a controlled vlan. Afterward, check the binding table to confirm the DHCP server's response and use the MAC address table or neigbor discovery protocols like cdp/lldp  to trace the server's MAC address back to the uplink port.

If the DHCP server is connected through another switch, you can use cdp/lldp to identify the uplink port toward the next hop. Cross-reference this information with your network topology to pinpoint the exact port leading to the DHCP server.

In cases where the switch supports pinging the DHCP server, you can use the ARP table to locate the MAC address of the DHCP server and map it to a physical interface. However, if the switch no longer allows pinging the DHCP server, alternative methods like tracing the management gateway or DHCP traffic are more reliable.

Once you have identified the uplink port, your script can configure it as trusted for DHCP Snooping. Using Python libraries like Netmiko, you could automate the retrieval of routing, ARP, and MAC address table data, process it to identify the uplink port, and apply the necessary configuration commands. 

 

Best regards
.ı|ı.ı|ı. If This Helps, Please Rate .ı|ı.ı|ı.

images (1).png

You can know which port connect to server by check type of message

MHM 

Excellent.

But how to check the type of message?

Thanks