Posted on 07-02-2018 04:14 PM
I am looking for a way to configure proxy settings via JSS, but in a little bit of a dynamic way. What we want to do is, when a computer is on our internal network, point to a different proxy than when off network. I would like to do this with a Configuration Profile but would be open to scripting if necessary.
Posted on 07-02-2018 04:35 PM
This is the scripted solution we are using, populate variables as required. It's only turning things on so you might need a variation to turn things back off.
#!/bin/bash
IP_Subnet=""
Search_Domain=""
Bypass_Domain=""
if [ "$(sw_vers -productVersion | awk -F "." '{print $2}')" -gt 6 ]; then
Network_Services=$(/usr/sbin/networksetup -listallnetworkservices | awk '!/*/ && !/Bluetooth/')
IFS=$'
'
for Network_Service in ${Network_Services}; do
echo checking $Network_Service
if [ "$(/usr/sbin/networksetup -getinfo "$Network_Service" | awk '/'$IP_Subnet'/ && /IP address:/')" ];then
echo $Network_Service needs to be checked
if [[ "$(/usr/sbin/networksetup -getproxyautodiscovery "$Network_Service" | awk /Off/)" ]]; then
echo setproxyautodiscovery
/usr/sbin/networksetup -setproxyautodiscovery "$Network_Service" On
fi
if [[ "$(/usr/sbin/networksetup -getinfo "$Network_Service" | awk '/IPv6: On/')" ]]; then
echo setv6off
/usr/sbin/networksetup -setv6off "$Network_Service"
fi
if [[ -z "$(/usr/sbin/networksetup -getsearchdomains "$Network_Service" | awk /$Search_Domain/)" ]]; then
echo setsearchdomains
/usr/sbin/networksetup -setsearchdomains "$Network_Service" $Search_Domain
fi
if [[ -z "$(/usr/sbin/networksetup -getproxybypassdomains "$Network_Service" | awk /$Bypass_Domain/)" ]]; then
echo setproxybypassdomains
/usr/sbin/networksetup -setproxybypassdomains "$Network_Service" "*.$Bypass_Domain"
fi
fi
done
fi
Posted on 07-03-2018 03:12 AM
There are various methods to achieve it however my preferred option would be to create the appropriate configuration policies and scope them with a target group of "All Computers" and limit it to a network segment.