You can use /etc/hosts to set up local domains but you can also block access to websites using the same syntax.

You only need to redirect the website domain to your own computer ( For example, to block, edit /etc/hosts/ file (with root permissions) and add the following line:

# /etc/hosts

Save the file and check you cannot access with curl or a web browser.

$ curl -I
curl: (7) Failed to connect to port 80 after 0 ms: Connection refused

This rule blocks (including http and https) but doesn’t block unless you add another rule.

# /etc/hosts

You can add as many rules as you want.

If you have any suggestion, feel free to contact me via social media or email.