<edit>
update the script to allow correct processing for strict.bing.com entry</edit>
Possible solution:
Create update_hosts.sh, make the script executable
#!/bin/bash
update_ip_address() {
file=/etc/hosts
if [[ $(grep $1 $file) ]]; then
IP=$(dig +noall +answer +short @8.8.8.8 $1 | \
grep -oE '((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){3}((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]))')
sed -i "/$1/ s/.*/$IP\t$1/g" $file
fi
}
update_ip_address restrict.youtube.com
update_ip_address restrictmoderate.youtube.com
update_ip_address strict.bing.com
update_ip_address forcesafesearch.google.com
Run sudo ./update_hosts.sh to update the hosts file or create a cron file to do it for you.