Have standard DNS everywhere

Mahmed1998
New Contributor

Hey Guys,

I'm using Jamf Now plus. To create profile I use profile creator. I want to create a profile where all the laptops in my company have 9.9.9.9 as their standard DNS. So when I go to home and I connect to my home Wi-fi the DNS will be 9.9.9.9. I don't want to do it manually is it possible to fix this?

7 REPLIES 7

blackholemac
Valued Contributor III

Is this for purposes of a web filter? If so may inquire which one?

blackholemac
Valued Contributor III

Here is how Securly does it for their web filter using an MDM pushed script:

https://support.securly.com/hc/en-us/articles/217657128-How-to-filter-Mac-OS-X-devices-off-site-?mobile_site=true

mojo21221
Contributor II

There would be a couple ways you could approach this task. You could create a policy utilizing Files and Processes --> then Execute Command below
networksetup -setdnsservers Wi-Fi 9.9.9.9

You could take it one step further and create an Extension Attribute to report what their DNS is

#!/bin/sh
echo "<result>`/usr/sbin/networksetup -getdnsservers Wi-Fi`</result>"

Next create some smart groups to report on said dns (is 9.9.9.9) (is not 9.9.9.9)

Then scope smart group to report on said Extension Attribute to execute the policy on their device again if it were to no longer be using 9.9.9.9

I wrote all of this from off the top of my head, so I would recommend testing it before going live. Hope this helps and welcome to jamf :)

mojo21221
Contributor II

@blackholemac I like your method a little better, adds more functionality..

#!/bin/bash
servers="9.9.9.9"
networksetup -listallnetworkservices | sed 1d $file | while read adapter
do
    networksetup -setdnsservers "$adapter" $servers
    networksetup -setv6off "$adapter"
done
dscacheutil -flushcache
exit 0

Mahmed1998
New Contributor

@mojo21221 Where do you add the script in Jamf NOW plus. Sorry for the question I'm not that good with JAMF. Should I add in into a package and thanks for the warm welcome :)

Mahmed1998
New Contributor

@blackholemac we are currently using quad 9 (https://www.quad9.net/)

florian_wenzel
New Contributor

Is it possible to use this kind of script on iOS? I need to get global DNS to work and i have absolutely no experience with jamf/iOS at all