If you have seen that stupid ! beside your WIFI or MobileData icons in Android, you have discovered the „Captive Portal Detection“ which has been added in KitKat or so. It’s terribly bugged if you are using a firewall in Android plus if you don’t, your device connects to Google every time you go online.
Since Marshmallow this behaviour can’t be disabled permanently. Captive Portal Detection is being reenabled after every boot.
So use your favourite script runner app (Tasker can do it) to run these commands at boot time to disable the crap:
settings put global captive_portal_detection_enabled 0 settings put global captive_portal_server localhost