The application provides a method for dynamically obtaining IP under unopened DHCP, comprising the following steps: S1, adding a socket process for monitoring the 67 port; S2, determining whether the ClientMACaddress in the dhcpdiscover message is 0005ca112233, if yes, then starting the relevant action, otherwise discarding; S3, if the ClientMACaddress is determined as 0005ca112233, then automatically setting the
IP address of the LAN port and starting the dhcp and
telnet or SSH
server, and simultaneously closing the debug_dhcp process; S4, through the execution of steps S1-S3, the device normally interacts through the DHCP protocol; S5, after the PC obtains the IP, the
telnet / SSH is performed to the device for debugging; S6, after the debugging is completed, the corresponding function is closed, and the original state is restored. Beneficial effects: the method can connect the device to perform the
telnet debugging under the condition that the DHCP is not opened on the device and no IP is configured, the original intention of the customer for the
network security is considered, the relevant function is automatically started only during the debugging, and the function is automatically closed after the debugging is completed.