The application discloses a method and
system for preventing DHCP spoofing, which comprises the following steps: firstly, obtaining a DHCP packet based on a controller, and extracting a source
MAC address according to the obtained DHCP packet; secondly, judging whether the source
MAC address matches a
MAC address in a
DHCP Snooping binding table; if yes, setting an uplink port as a trusted port; if no, deleting the DHCP packet, and marking a source MAC address corresponding to the DHCP packet with a discarded time number as 1; finally, judging whether the discarded time number of the source MAC address corresponding to the DHCP packet is greater than N; if yes, listing the source MAC address in a
blacklist; if no, ending the process.