OT - Add bypass Proxy via command line

myronjoffe
Contributor III

Is there a way via command line networksetup -setproxybypassdomains to add to the existing bypass domains without replacing what already exists on the list?

1 REPLY 1

jelockwood
Contributor

I used the following script recently to check for existing settings and then add a new one.

#!/bin/bash
# Get current VPN proxy bypass settings for interface called VPN
CURRENT=networksetup -getproxybypassdomains VPN
# if result contains the word bypass then it was empty because it has included an error message therefore set variable to empty
if [[ $CURRENT = *bypass* ]]
then CURRENT=""
fi
# If new entry not in list then
if [[ $CURRENT != *10.0.0.21* ]]
then
# add new bypass entry CURRENT="$CURRENT 10.0.0.21"
# write new list to setting networksetup -setproxybypassdomains VPN $CURRENT
fi
# read list again to verify
CURRENT=networksetup -getproxybypassdomains VPN
echo $CURRENT
exit