There are some services that require dynamic IP, so we use the method of restarting the router. Manual restarts are not optional and can be performed with timed scripts. Paste code, each router, the prompt is not the same. Requires the router to have Telnet function only line.
#!/usr/bin/env python#-*-coding:utf-8-*-import telnetlibhost = "192.168.1.1" USER = "admin" PASS = "admin" router = Teln Etlib. Telnet (HOST) router.set_debuglevel (2) Router.read_until ("Username:") router.write (USER + "\ r \ n") Router.read_ Until ("Password:") router.write (PASS + "\ r \ n") router.read_until ("Tp-link >", Router.write ("enable\r\n") Router.read_until ("Enter Password:") router.write (PASS + "\ r \ n") Router.read_until ("Tp-link #") Router.write (" SYS reboot\r\n ") router.read_until (" Continue, ") Router.write (" y\r\n ") Router.close () print" Done "
This article is from the "[email protected]" blog, please be sure to keep this source http://ribble.blog.51cto.com/3863110/1696802
Python implements restart router