Last active
May 12, 2023 03:10
-
-
Save jonathanhle/9a6966d0a6296bf071ff8ba7c74c71d6 to your computer and use it in GitHub Desktop.
umbrella_dns_changer for osx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ----------------------------------------------------------- | |
# Get installed OSX Network Devices and then list the ones with Active Internet Connections | |
# ----------------------------------------------------------- | |
InstalledHardware=$(networksetup -listallhardwareports | grep Device | awk '{print $2}') | |
ActiveInterfaces=$(ifconfig | pcregrep -M -o '^[^\t:]+(?=:([^\n]|\n\t)*status: active)') | |
# ----------------------------------------------------------- | |
# Get list of active network devices | |
# ----------------------------------------------------------- | |
common_live_network_devices=$(for installedDevice in ${InstalledHardware} | |
do | |
for activeDevice in ${ActiveInterfaces} | |
do | |
if [ "${installedDevice}" = "${activeDevice}" ] | |
then | |
echo "${activeDevice}" | |
fi | |
done | |
done) | |
# ----------------------------------------------------------- | |
# Find the common device names and set the setdnsservers to Umbrella | |
# Common like "Wi-Fi" and "Thunderbolt Ethernet Slot 1" | |
# ----------------------------------------------------------- | |
for common_device in ${common_live_network_devices} | |
do | |
internet_device=$(networksetup -listallhardwareports | grep -B 1 ${common_device} | grep "Hardware Port" | cut -c 16-) | |
hello=$(echo networksetup -setdnsservers \"${internet_device}\" 208.67.222.222 208.67.220.220) | |
eval $hello | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
used https://apple.stackexchange.com/questions/402913/convert-bash-script-to-a-compiled-standalone-binary-executable-not-text to make a binary like following: