Automatically turn off and turnon router

Router control system using arduino

I use Grbl and a CNC shield to control my router. But maybe that won't work with yours. Hard to say because you have provided no information.

I was thinking WiFi router when I read the headline but there are indeed very different kind of routers out there.