mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 11:42:21 +08:00
21 lines
503 B
Bash
21 lines
503 B
Bash
#!/bin/bash
|
|
nic=$(route -n get default | grep "interface" | awk '{print $2}')
|
|
|
|
hardware_port=$(networksetup -listallhardwareports | awk -v dev="$nic" '
|
|
/Hardware Port:/{
|
|
port=$0; gsub("Hardware Port: ", "", port)
|
|
}
|
|
/Device: /{
|
|
if ($2 == dev) {
|
|
print port;
|
|
exit
|
|
}
|
|
}
|
|
')
|
|
|
|
if [ -f original_dns.txt ]; then
|
|
original_dns=$(cat original_dns.txt)
|
|
networksetup -setdnsservers "$hardware_port" $original_dns
|
|
rm -rf original_dns.txt
|
|
fi
|