Bandwidth exhaustion not detected on WAN links
-
Is there a way to automatically detect bandwidth depletion on a WAN link and disable the gateway?
Some ISPs don't block everything once you have consumed your bandwidth quota, instead they limit the amount of data that can be transmitted per session.
DNS lookups, ping to the gateway or monitor IP succeeds as well as a traceroute but http requests fail.Performing a curl request to https://connectivitycheck.gstatic.com/generate_204 detects this and exits with a 28 operation timeout exit code when blocked.
curl --interface xxx.xxx.xxx.34 --insecure --connect-timeout 2 --max-time 4 'http://connectivitycheck.gstatic.com/generate_204' ; echo $? curl: (28) Operation timed out after 4013 milliseconds with 0 bytes received 28
curl --interface xxx.xxx.xxx.50 --insecure --connect-timeout 2 --max-time 4 'http://connectivitycheck.gstatic.com/generate_204' ; echo $? 0
All of the following URLs (services) work for the test but only the Google one works without SSL.
https://detectportal.firefox.com
https://conncheck.opensuse.org
https://connectivitycheck.gstatic.com/generate_204
http://connectivitycheck.gstatic.com/generate_204I have tried several others but they didn't get blocked since not enough data was transferred.
Thanks