Programming, tutorials, mechatronics, operating systems, and other tech stuff

TP-Link Access Point/router batch reboot/restarter php script

117 comments
Untuk versi bahasa indonesia, silahkan klik disini

If you have a large wireless network infrastructure, which consist of many Access point and Wi-Fi router. And at some cases, you need to safely reboot all access point. It could be very annoying if you have to login to each AP/Router and restart them individually one by one.

Why bother doing all those work manually when you could write a code to do it automatically?

Well, luckily in my cases, all of the access point have the same brand. it's TP-Link. After some research, i found a way to reboot those brand's access point and router by using URL. Then i wrote this PHP script to get the job done.

In my infrastructure, i made all access point and router have different IP sub from DHCP-ed network. All have same username and password, all have the same method of authentication (using http auth). This script written in PHP, running in terminal/console. So it's very handy when it comes to automation. Just add it to cron and voila. Don't forget to make it executable "chmod 777" if you want to run it under linux and make sure you have php5-cli installed.

Here i share the script i wrote, you can customize it to suit your infrastructure, be creative.


#!/usr/bin/php

<?php

//----------Auth config

$apUser="admin";

$apPass="admin";

//----------Lists of AP and it's IP address

$apList=Array(

Array("Ext1","192.168.0.15"),

Array("Ext2","192.168.0.17"),

Array("Jalak","192.168.0.2"),

Array("Barat","192.168.0.3"),

Array("-","192.168.0.5"),

Array("Parkit","192.168.0.6"),

Array("Murai","192.168.0.9"),

Array("Nuri","192.168.0.10"),

Array("Kenari","192.168.0.12"),

Array("Cucak","192.168.0.13"),

Array("Hud-Hud","192.168.0.14"),

);



function curl_download($ip){

$Url="http://".$ip."/userRpm/SysRebootRpm.htm?Reboot=Reboot";

// is cURL installed yet?

if (!function_exists('curl_init')){

die('Sorry cURL is not installed!');

}



// OK cool - then let's create a new cURL resource handle

$ch = curl_init();



// Set URL to download

curl_setopt($ch, CURLOPT_REFERER, "http://".$ip."/userRpm/SysRebootRpm.htm");

curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Ubuntu; Linux i686;rv:12.0) Gecko/20100101 Firefox/12.0");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_URL, $Url);

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

curl_setopt($ch, CURLOPT_USERPWD, $apUser.":".$apPass);

curl_setopt($ch, CURLOPT_TIMEOUT, 120);



$output = curl_exec($ch);



curl_close($ch);



return $output;

}



print "\n";

print "\e[1;34mAP Resetter. By Cybermujahidz\e[0m\n";

print "\n";

print "List of AP:\n";

foreach($apList as $ap){

print str_pad($ap[1],15,' ',STR_PAD_RIGHT)." ".str_pad($ap[0],10,' ',STR_PAD_RIGHT)." queued\n";

}

print "\n";

print "Resetting ALL AP\n";

print "----------------\n";

foreach($apList as $ap){

if(curl_download($ap[1])){

print str_pad($ap[1],15,' ',STR_PAD_RIGHT)." ".str_pad($ap[0],10,' ',STR_PAD_RIGHT)." [ \e[1;32mAP Rebooted\e[0m ]\n";

}else{

print str_pad($ap[1],15,' ',STR_PAD_RIGHT)." ".str_pad($ap[0],10,' ',STR_PAD_RIGHT)." [ \e[1;31m AP Down \e[0m ]\n";

}

}

print "AP reset finished.\n";

print "------------------\n";

?>

117 comments :

  1. This technical post helps me to improve my skills set, thanks for this wonder article I expect your upcoming blog, so keep sharing...
    Regards,
    PHP Training in Chennai

    ReplyDelete
  2. Great blog.. I found some useful info in your article, it was awesome to read, thanks for sharing this great content to my vision.. Software Testing Training Institute in Chennai | Selenium Training Institute in Chennai | ISTQB Training Institute in Chennai

    ReplyDelete
  3. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.

    java training in bangalore

    ReplyDelete
  4. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
    Web Designing Training Institute in Chennai | Web Designing Training Institute in Velachery

    ReplyDelete
  5. Best of luck for your next blog.
    Thank you for such a wonderful article and sharing.God bless you.!!!!
    Best CorelDraw Training Institute in Chennai | No.1 CorelDraw Training Institute in Velachery

    ReplyDelete
  6. Nice post.Great information on this blog, many useful and new ideas i'm learning here.It's very helpful.
    Best AWS Training Institute in Chennai | Best AWS Training Institute in Velachery

    ReplyDelete
  7. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
    MCA Project Center in Chennai | MCA Project Center in Velachery

    ReplyDelete
  8. Thanks for sharing such a great blog post. I really like your blog post which is so informative.
    white label website builder

    mobile website builder

    ReplyDelete
  9. Very good and informative article. Thanks for sharing such nice article, keep on updating...
    Best AWS Training Institute in Chennai | Best AWS Training Institute in Velachery

    ReplyDelete
  10. Excellent Blog very imperative good content, this article is useful to beginners and real time Employees. Selenium Training in Chennai| Oracle Training in Chennai

    ReplyDelete
  11. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.. Big Data Training in Chennai Digital Marketing Training in Chennai

    ReplyDelete
  12. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information. iOS Training in Chennai | iOS Training institutes in Chennai

    ReplyDelete
  13. Concepts are very clear. Thank you for sharing such a valuable content. we are very happy to receive such a nice one Thank you... Devops Training in Chennai | AWS Training in Chennai

    ReplyDelete
  14. I wish to show thanks to you just for bailing me out of this particular trouble. As a result of checking through the net and meeting techniques that were not productive, I thought my life was done... iOS Training in Chennai | Big Data Training in Chennai

    ReplyDelete
  15. Very nice article this would definitely help the beginners, coding made easy with the help of example you shared... Oracle Training in Chennai | Selenium Training in Chennai

    ReplyDelete
  16. If you are going for finest contents like me, simply pay a quick visit this web page every day since it presents feature contents, thanks.
    Excellent Summer Courses in Guindy | Best Summer Classes in Chennai

    ReplyDelete
  17. Awesome post. Really you are shared very informative concept... Thank you for sharing. Keep on updating...
    Dot-net Summer Course training Institute in Chennai|Dot-net Summer Course training Institute in Ashok Nagar

    ReplyDelete
  18. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
    Dotnet Training Institute in Chennai |Dotnet Training Institute in Velachery

    ReplyDelete
  19. Excellent information...It was getting more information about your blog. Thanks for sharing, keep updating.
    AWS Training Institute in Chennai|AWS Training Institute in Velachery

    ReplyDelete
  20. Very good and informative article. Thanks for sharing such nice article, keep on updating such good articles.
    Best cloud Computing Training Institute in Chennai | Best cloud Computing Training Institute in Velachery

    ReplyDelete
  21. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
    Best MCSE/MCSA Certificate Training Institute in Chennai|Best MCSE/MCSA Certificate Training Institute in Velachery

    ReplyDelete
  22. Thanks admin, your blog gives lots of information to me. Keep sharing more like this..DotNet Project Center in Chennai | DotNet Project Center in Velachery

    ReplyDelete
  23. Awesome..You have clearly explained.Its very useful for me to know about new things..Keep on blogging.
    InDesign Certification Center in Chennai | No.1 InDesign Training in Keelkattalai

    ReplyDelete
  24. Such a cute blog. Thank you for blogging. Keep adding more blogs. Very nicely presented.

    ReplyDelete
  25. Wonderul post to sharing..Thank you..DotNet Project Center in Chennai | <a href="https://www.alltechzsolutions.in/dotnet-project.phpDotNet Project Center in Velachery</a>

    ReplyDelete
  26. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.

    IBM BPM Online Training in Chennai
    IBM BPM Online Training

    ReplyDelete
  27. Thanks for your informative article. Your post helped me to understand the future and career prospects. Keep on updating your blog with such awesome article.
    Python Certification Center in Chennai | No.1 Python Exams in Nanganallur

    ReplyDelete
  28. Great blog.. I found some useful info in your article, it was awesome to read, thanks...
    BE Final Year Project Center in Chennai | BE Project in Madipakkam

    ReplyDelete
  29. Great survey, I'm sure you're getting a great response. https://192-168-i-i.com

    ReplyDelete
  30. This is really too useful and have more ideas from yours. keep sharing many things and thanks for sharing the information.

    Best python training institute in Kanchipuram

    ReplyDelete
  31. Nice and informative article. Thanks for sharing such nice article, keep on updating.

    CandC++ programming training academy in Kanchipuram

    ReplyDelete
  32. Nice post... Really you are done a wonderful job. Thanks for sharing such wonderful information with us. Please keep on updating...

    Best Java Training Academy in Kanchipuram

    ReplyDelete
  33. Nice Post.Great information and really very much useful. Thanks for sharing and keep updating.

    Best Graphics Desingning Training Academy in Kanchipuram

    ReplyDelete
  34. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing

    Best AWS Training Academy in Kanchipuram

    ReplyDelete
  35. Really very great information to be provided and the All points discussed were worth reading and i’ll surely work with them all one by one.
    Best C and C++ Programming Training Academy in Kanchipuram

    ReplyDelete
  36. Awesome post. Really you are shared very informative concept... Thank you for sharing. Keep on updating...

    Best Graphics Designing Training Academy in Kanchipuram

    ReplyDelete
  37. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…

    Best Web Designing Training Academy in Kanchipuram

    ReplyDelete
  38. Awesome post. Really you are shared very informative concept... Thank you for sharing. Keep on updating...

    Best Java Training Academy in Kanchipuram

    ReplyDelete
  39. Wonderful post. Thank you for updating such an informative content.


    Best Python Training Academy in Kanchipuram

    ReplyDelete
  40. Thanks for this greatful information. all this information is very important to all the users and can be used good at all this process
    Best Tally ERP 9.0 Training Academy in Kanchipuram

    ReplyDelete
  41. Thank you so much for sharing. Keep updating your blog. It will very useful to the many users.
    Best Web Designing Training Academy in Kanchipuram

    ReplyDelete
  42. I have read your blog its very attractive and impressive. I like it your blog.
    Best Software Testing Training Academy in Kanchipuram

    ReplyDelete
  43. Your Blog is nice and informative..Thanks for sharing this valuable information with us..I am visiting this website regularly, this web site sharing nice thoughts

    Best MATLAB Training Academy in Kanchipuram

    ReplyDelete
  44. Thanks for sharing this niche useful informative post to our knowledge...
    Best java Training Academy in Kanchipuram

    ReplyDelete
  45. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me

    Best Cloud Computing Training Academy in Kanchipuram

    ReplyDelete
  46. Thanks for this grateful information. all this information is very important to all the users and can be used good at all this process.


    Best Web Designing Training Academy in Kanchipuram

    ReplyDelete
  47. This information is very useful and innovative..I gained more knowledge from this.Thanks for the nice information its very useful to read your blog...
    Best web designing Training Institute in in Kanchipuram

    ReplyDelete
  48. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site
    Best dotnet Training Institute in Kanchipuram

    ReplyDelete
  49. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site
    Best web design Training Institute in Kanchipuram

    ReplyDelete
  50. thank you for such a great article with us. hope it will be much useful for us. please keep on updating..
    Best software testing Training Institute in Kanchipuram

    ReplyDelete
  51. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us.
    Best dally erp 9 Training Institute in Kanchipuram

    ReplyDelete
  52. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
    Best web designing Training Institute in Kanchipuram

    ReplyDelete
  53. Wonderful article.It is to define the concepts very well.Clearly explain the information.It has more valuable information for encourage me to achieve my career goal.
    Best JAVA and J2EE Training Institute in Kanchipuram

    ReplyDelete
  54. Wow!! What a interesting blog..Thanks The information which you provided is very much useful and easy to learn as well...keep rocking and updating... looking further..
    Best CCNA Training Institute in Kanchipuram

    ReplyDelete
  55. Nice post. I study something more challenging on completely different blogs everyday.
    Best JAVA and J2EE Course Training Institute in kanchipuram|

    ReplyDelete
  56. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Best Graphic Designing Course Training Institute in kanchipuram|

    ReplyDelete
  57. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    Best Advanced Amazon Web Services Course Training Institute in kanchipuram|

    ReplyDelete
  58. Great Post with lots of useful informations. Excellent blog very much interesting...
    SAP Training in Chennai | AWS Training in Chennai | SAP Training | AWS Training

    ReplyDelete
  59. I would like to thank you for your nicely written post, its informative and your writing style encouraged me to read it till end. Thanks
    Best Graphic Designing Course Training Institute in kanchipuram|

    ReplyDelete
  60. Excellent Blog very imperative good content, this blog is useful to beginners.
    Best Selenium Automation Course Training Institute in kanchipuram|

    ReplyDelete
  61. I think this is an informative post and it is very useful and knowledgeable. I really enjoyed reading this post. thank you!
    Best Python Course Training Institute in kanchipuram|

    ReplyDelete
  62. hi, nice information is given in this blog. Thanks for sharing this type of information, it is so useful for me. nice work keep it up
    Best tally erp9 Course Training Institute in kanchipuram|

    ReplyDelete
  63. REALLY VERY EXCELLENT INFORMATION. I AM VERY GLAD TO SEE YOUR BLOG FOR THIS INFORMATION. THANKS FOR SHARING. KEEP UPDATING.
    Best Hardware and Networking Course Training Institute in kanchipuram|

    ReplyDelete
  64. This post was quite awesome and interesting to read. Congrats for your work. Thanks a lot for providing this with us. Keep on updating this with us regularly:
    Best Selenium Automation Course Training Institute in kanchipuram|

    ReplyDelete
  65. The best thing is that your blog really informative thanks for your great information
    Best tally erp 9 Course Training Institute in kanchipuram|

    ReplyDelete
  66. Awesome Blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog...
    Best Linux Certification Course Training Institute in kanchipuram|

    ReplyDelete
  67. Great post.Thanks for one marvelous posting! I enjoyed reading it;The information was very useful.Keep the good work going on!!
    Best Graphic Designing Course Training Institute in kanchipuram|

    ReplyDelete
  68. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Best UIPath Robotic Process Automation Course Training Institute in kanchipuram|

    ReplyDelete
  69. Nice and good blog. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating....No:1 Selenium Automation Training Academy in Kanchipuram

    ReplyDelete
  70. The information you have here is really useful to make my knowledge good. It is truly supportive for us and I have accumulated some essential data from this blog.
    Best JAVA and J2EE Course Training Institute in kanchipuram|

    ReplyDelete
  71. Your Blog is really awesome with helpful post..keep updating such an excellent post with us..
    Best CCNA Course Training Institute in kanchipuram|

    ReplyDelete
  72. Great blog.you put Good stuff.All the topics were explained briefly.so quickly understand for me.I am waiting for your next fantastic blog.Thanks for sharing.
    Best Tally erp9 Course Training Institute in kanchipuram|

    ReplyDelete
  73. Nice..You have clearly explained about it ...Its very useful for me to know about new things..Keep on blogging..
    Best JAVA and J2EE Course Training Institute in kanchipuram|

    ReplyDelete
  74. Hi, am a big follower of your blog. I am really happy to found such a helpful and fascinating post that is written in well manner. Thanks for sharing such an informative post. keep update your blog.
    Best CCNA Course Training Institute in kanchipuram|

    ReplyDelete
  75. Great post.Thanks for one marvelous posting! I enjoyed reading it;The information was very useful.
    Best Best Web Designing and Development Course Training Institute in kanchipuram|

    ReplyDelete
  76. great doing. and i happy to visit your blog to know about this wonderful information. thanks for sharing. keep updating.
    Best Best Web Designing and Development Course Training Institute in kanchipuram|

    ReplyDelete
  77. Your info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog..
    Best Python Course Training Institute in kanchipuram|

    ReplyDelete
  78. Very impressive and informative blog.. thanks for sharing your valuable information.. it is very useful and easy to learn as well... keep rocking and updating... looking further..
    Best Tally Erp9.0 Course Training Institute in kanchipuram|

    ReplyDelete
  79. Quite Interesting post!!! Thanks for posting such a useful post. I wish to read your upcoming post to enhance my skill set, keep blogging.
    Best Web Technologies Course Training Institute in kanchipuram|

    ReplyDelete
  80. Useful information and kindly keep update such a nice blog. Thanks for sharing......No:1 CCNA Training Academy in Kanchipuram

    ReplyDelete
  81. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information, this is useful to me…
    Best Linux Certification Course Training Institute in kanchipuram|

    ReplyDelete
  82. Quite Interesting post!!! Thanks for posting such a useful post. I wish to read your upcoming post to enhance my skill set, keep blogging.
    Best Web Technologies Course Training Institute in kanchipuram|

    ReplyDelete
  83. Nice Post! It is really interesting to read from the beginning & I would like to share your blog to my circles, keep your blog as updated.
    Best Tally ERP 9 Course Training Institute in kanchipuram|

    ReplyDelete
  84. Interesting post! This is really helpful for me. I like it! Thanks for sharing!
    Best Graphic Designing Course Training Institute in kanchipuram|

    ReplyDelete
  85. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me
    Best PCB Training Course Training Institute in kanchipuram|

    ReplyDelete
  86. This is excellent information. It is amazing and wonderful to visit your site.Thanks

    for sharing this information, this is useful to me…no:1selenium automation training institute in kanchipuram.

    ReplyDelete
  87. your blog contain very useful information. Really hereafter I am very big follower of your blog..
    Best MATLAB Course Training Institute in kanchipuram|

    ReplyDelete
  88. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information, this is useful to me…no:1
    HP QTP / UFT Automation training institute in kanchipuram.

    ReplyDelete
  89. Great post....Thank you for posting the great content……I found it quiet interesting, hopefully you will keep posting such blogs…Keep updating your creative and awesome blog.
    Best Tally Erp9 Course Training Institute in kanchipuram|

    ReplyDelete
  90. The best thing is that your blog really informative thanks for your great information! I have got some important suggestions from it.
    Best Printed Circuit Board (PCB) Course Training Institute in kanchipuram|

    ReplyDelete
  91. The information you have deliver here is really useful to make my knowledge good. Thanks for your heavenly post.
    Best Best Web Designing and Development Course Training Institute in kanchipuram|

    ReplyDelete
  92. Your post explain everything in detail and it was very interesting to read. Thank you sharing.
    Best Tally Erp9 Course Training Institute in kanchipuram|

    ReplyDelete
  93. I am read your post was very interesting good valid information
    keep sharing more information...
    Best Tally Erp9 Course Training Institute in kanchipuram|

    ReplyDelete
  94. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information, this is useful to me…
    Best Tally Erp9 Course Training Institute in kanchipuram|

    ReplyDelete
  95. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing.
    No:1 Tally Training Academy in kanchipuram

    ReplyDelete
  96. Really it was an awesome information...very interesting to read..You have provided an nice blog....Thanks for sharing..
    Best JAVA / J2EE / J2ME Course Training Institute in kanchipuram|

    ReplyDelete
  97. Excellent post. I have read your blog it's very interesting and informative. Keep sharing.
    Best JAVA / J2EE / J2ME Course Training Institute in kanchipuram|

    ReplyDelete
  98. Nice post.. Really you are done a wonderful job. Thanks for sharing such wonderful information with us. Please keep on updating...
    Best C & C++ Course Training Institute in kanchipuram|

    ReplyDelete
  99. Very nice post here and thanks for it .I always like and such a super blog of these post.Excellent and very cool idea and great blog of different kinds of the valuable information's.
    Best Tally Erp 9.0 Course Training Institute in kanchipuram|

    ReplyDelete