Check if computer is connected to the internet Write a program which, according to whether the script has access to the internet, produces an output which is "Truthy/Falsey". You may try and connect to any existing site, at your own discretion (don't use a shady site which only has 10% uptime - try to keep to above 80% annual uptime). If the site is down, your program does not have to work.

It must be a standalone program or a function. You may use libraries outside of the standard library to achieve this. Standard loopholes are forbidden. This is code golf, so the code with the shortest byte-count wins. 

Example pseudocode:

function a:
    try:
        connect to internet 
        return 1
    catch error:
        return 0


This is my first post on code golf, so if this violates any rules in any way or is a dupe, please alert me.

EDIT: Due to numerous suggestions, I have removed the UTF-8 byte count restriction
Bash (with dnsutils), 3 bytes
Sends a DNS request for &quot;.&quot; (DNS root), exit code is 0 for success and &gt;0 otherwise.
Golfed
dig

Test
% dig &gt;/dev/null; echo $?;        
0

% nmcli nm wifi off
% dig &gt;/dev/null; echo $?;
9

Disclaimer
This will obviously only work if your DNS server is sitting in the provider's network, i.e. in the &quot;Internet&quot; (as your provider network is normally a part of it), or if your system is using a public DNS server (like 8.8.8.8 from Google, which Android based systems use), as otherwise, you can get a cached copy from a local LAN server (or localhost).
But I assume this is not against the code-golf rules, as there are obviously more than one system where this does work as intended.
Pure-HTTP methods can also give false positives, due to an intermediate caching proxy, and are not guaranteed to work everywhere, so that is not something unique to this method.
A slightly more reliable version, 8 bytes
dig +tra

(a little tribute to @Digital Trauma !)
Enables the &quot;trace mode&quot;, which will force dig to do the recursive search by itself (see https://serverfault.com/a/778830), avoiding any cache issues.