This question is very much related to Router reboots when using Nmap, the difference is that I'm actually interested in a practical solution to this problem.

I have a piece of C code that is doing port scans with raw sockets. The port I'm interested in is very rarely open, therefore I would want to increase my scan rate. But as soon as I increase the rate, my router starts to reboot.

Now, the answer to the related thread linked above says

You are probably exhausting the router's resources, primarily the NAT table.

So, I have first tried to get some indicators (for router is going to fail soon) from the C code itself. So I checked the return values from sendto and errno and so on, but it just does not indicate that something is going wrong badly. Is there any way I can get some indicator from inside the C code that tells me that I have to slow down in order to prevent the router from rebooting?

The other thing I've tried to do is port forwarding, but it does not work, the router is still rebooting. I must admit I am not so much of an expert for routers and NAT tables, but I was thinking that there is no mapping involved for every new outgoing connection if the source port is forwarded. Is it wrong to think that port forwarding is going to help for this case, if so why?

  • I'm not sure why you are hoping to get insight from the code instead of looking at the router's side.
    – schroeder
    Commented Oct 26, 2019 at 12:29
  • What kind of port forwarding? What is being forwarded? Are you scanning the router, or where is your target?
    – schroeder
    Commented Oct 26, 2019 at 12:31
  • This has been flagged as not being a security question, and I'm going to have to agree. The nmap question is borderline (because it is a security tool), what you have here is custom code and a troubleshooting problem. I'm not seeing the security issue. Get packet captures and look at the router's logs.
    – schroeder
    Commented Oct 26, 2019 at 12:37
  • Hmm ok thank you anyway, so can you move it to stackoverflow or should I post it there then?
    – ezegoing
    Commented Oct 26, 2019 at 12:41
  • SO will want to see the code, see the results, and will want to see the router's side.
    – schroeder
    Commented Oct 26, 2019 at 12:43


Browse other questions tagged .