There are several ways to achieve this:
Some Routers allow Whitelisted websites and block the blocklists.
You can modify the hosts file to allow whitelisted websites only.
Apply firewall rules to allow whitelisted URLs only.
Set up a custom DNS server that allows whitelisting specific domains.