Jayden

Jayden

PAC (Proxy Auto-Config)

I have been troubled by one thing for a long time:

  • I am a heavy macOS user and it is easy for me to solve almost all network problems on macOS, thanks to excellent software like Surge for Mac.

  • However, things are more complicated on Windows and Linux, but using Windows or Linux is still necessary.

  • I don't want to deploy software and write configuration files for each system.

Therefore, the best practice is to use Surge for Mac as a proxy server to take over the network for other devices.

I am in a large intranet at school and cannot set the IP of my Mac to static, so I need to constantly update the IP address of my Mac to maintain this solution.

With the help of ChatGPT, I wrote a script that automatically obtains the IP address of my Mac and generates a PAC (Proxy Auto-Config) configuration file, which is uploaded to my cloud storage. Other devices only need to fill in the address of the configuration file.


  1. Save the following code as generate_pac.sh. This script will generate a proxy.pac file in the same directory and upload it to the cloud storage using the webdav feature of alist.

  2. Set up a scheduled task:

    Then add this line to the end (run every half hour, you can adjust it according to your needs):

This article is synchronized and updated to xLog by Mix Space.
The original link is https://xxu.do/posts/geek/PAC


Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.