Here was an interesting situation that I encountered recently; how do you force safe search on Google for a Guest network without a DNS server, SSL decryption or separate proxy server and just have a firewall (FortiGate). This utilizes the built-in web filter of FortiGate firewalls and configures a local DNS database that we will use as the FortiGate does not support CNAMEs. It is not perfect but we will make it harder to access adult content. This option is quite a bit better than blocking all images at Google (encryptedtbn0.gstatic.com) as the first few rows on an image search are Base64 encoded and not loaded from encryptedtbn0.gstatic.com. Bing is similar unless you are a school, in which you can register your public IP to force strict.bing.com but a similar option would be available. At the end of this document will be the scripts for each google country subdomain and possible ways to bypass these DNS settings.
- Setup your Guest outbound policy. We will modify it so it only allows HTTP and HTTPS access. You could also allow everything but put a DNS block above the policy, otherwise, the users can just specify an external DNS server and bypass your work.
- Change the DHCP server to use the FortiGate interface IP. If on the FortiGate, this can be found on the interface at Network > Interfaces.
- Go to System > Feature Visibility and enable DNS Database.
- Next, go to Network > DNS Servers and select Create New for the DNS Service on Interface.
- Select the interface from the drop-down and select the mode as Recursive. If you have FortiGuard services, you can also apply a DNS filter profile. Here are descriptions of each of these options:
- Forward – This just sends the request off to the configured DNS servers.
- Non-Recursive – This only uses the configured database and drops unresolved queries.
- Recursive – This uses the configured database first, and then sends on unresolved queries to the system configured DNS servers.
- Next, take the attached script and enter it on the firewall. System > Advanced > Configuration Scripts
- FortiGate Google DNS Settings
- Sample for Google.com:
- Run the following command from CLI to view your DNS records.
diagnose test application dnsproxy 8
- Set the DHCP server to give out the interface IP for DNS. If you use the FortiGate for DHCP, just go to Network > Interfaces and edit your interface with the Guest network.
- Hop on the Guest network and try searching on Google. It should now force safe search. You can also verify this by running “nslookup google.com”.
Bypass Google Safe Search:
- Manually visit google by looking up the IP address. This can be accomplished at a site like dnschecker.org. The site should still be allowed, however, you may receive certificate warnings.
- If you do not block DNS outbound, just manually configure an external DNS server like 188.8.131.52 or 184.108.40.206.