Category filter
Script to Allow/Block Websites on Mac
Web content filtering is an effective access control mechanism to allow/deny web access on the devices. Blocking specific websites or URLs on the browser helps an administrator prevent the user from spending effective business hours on irrelevant web pages and secure the device from malicious websites. However, if you want to limit web access to particular URLs, you can get it done by whitelisting them. This article enables you to perform web content filtering on macOS devices over the air using scripts deployed via the Execute Custom Script action.
Script to block access to specific websites
The Hosts files are an essential tool that enables you to modify how the device views a particular website. For example, we can use the Hosts files present on the device to block access to specific URLs. The following script helps you to edit the Hosts files on a device to block an unwanted website.
1 |
echo "127.0.0.1 www.facebook.com" >> /etc/hosts |
You can replace www.facebook.com with the necessary URL.
Script to allow access to the blocked websites
Just in case you want to permit access to the blocked websites on the Hosts files you can do it using the following script:
1 |
/usr/bin/sed -i "" '/127.0.0.1 www.facebook.com/d' /etc/hosts |