Its full name, Uncomplicated Firewall, might sound modest, but Ufw is a powerful firewall, and can be used to block access to certain websites. Although, technically, you can also do this with Dnsmasq, this would be a form of “DNS hijacking,” which is a rather dastardly procedure, usually carried out by scammers.
The advantage of using Ufw is that it blocks domains by IP address. This means you have to write down only one rule per address, rather than remember the various domains and subdomains used by sites. Imagine trying to block every variant of Facebook.com, for instance: fb.com, m.facebook.com, the list goes on.
It stands to reason, then, that in order to block websites by IP address, you need that information. Open Terminal on your Pi, or connect via…