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?