2

I would like to do a warm reset to my NETGEAR DGN2200 from a C# windows application, my modem is a standard Netgear modem/router. Is it possible without telnet?

Alex
  • 23,004
  • 4
  • 39
  • 73
Ian Hertzon
  • 53
  • 1
  • 3
  • Welcome to Stack Overflow. Did you try _anything_ so far? Show your effort first so people might show theirs. Please read [FAQ], [ask] and [help] as a start.. – Soner Gönül Mar 18 '14 at 07:15
  • You can always programmatically connect to it via telnet - http://stackoverflow.com/questions/390188/c-sharp-telnet-library – Blorgbeard Mar 18 '14 at 07:17
  • I suspect that netgear may, in time, have actually created more than one product that could be described as a modem router. Please try to actually identify what model you have, rather than just assuming that there is *a* standard. – Damien_The_Unbeliever Mar 18 '14 at 07:27
  • Thanks for your comment but netgear dgn2200 doesn't support Telnet. – Ian Hertzon Mar 18 '14 at 07:27
  • it's helpful that you identified your router model number in the comments, but people are not going to search the comments for that information. Also, you haven't provided any other relevant information as to what you have tried so far or the challenges you face with your code. If you have a general question about how the specific router works, their support center will be better equipped to help. – Claies Mar 18 '14 at 07:33
  • [NETGEAR Genie](http://www.netgear.com/home/discover/apps/genie.aspx) does it – Alex Mar 18 '14 at 07:59

1 Answers1

4

I hope this code will solve your question, this is how I restart my router from C# You can imitate a user's http request to the Netgear modem web interface at 192.168.0.1. you can use Fiddler to get the exact web request, just edit the right headers to the request. Pay attention to request.Headers["Authorization"] it should correlate with your Modem's username and password, it's usually "Admin" "Admin" with netgear but it might be preconfigured by your Internet service provider.

 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://192.168.0.1/reboot.cgi");
          request.Method = "POST";
        request.ContentType = "application/x-www-form-urlencoded";
        request.Referer = @"http://192.168.0.1/DIAG_diag.htm";
        request.UserAgent = @"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36";
        request.Accept = @"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
        request.Credentials = new NetworkCredential("Admin", "Admin");
        var requestBody = Encoding.UTF8.GetBytes("Reboot = Reboot");
        request.Host = "192.168.0.1";
        request.Headers["Authorization"] = "Basic QWRtaW46QWRtaW4=";
        request.Headers["Origin"] = @"http://192.168.0.1";
       using (var requestStream = request.GetRequestStream())
       {
           requestStream.Write(requestBody, 0, requestBody.Length);
       }

       string output = string.Empty;
       using (var response = request.GetResponse())
       {
           using (var stream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252)))
           {
               output = stream.ReadToEnd();
           }
       }