Recently, I found that the speed of installing some software using brew is too slow, and many installations fail due to timeout issues. Then I searched for many methods provided by netizens and found that most of them are no longer usable or have some minor errors. Therefore, I am rewriting an article on how to use the macOS terminal to bypass the Great Firewall.
Configure Proxy#
Process omitted
Assume that the final obtained port is HTTP 127.0.0.1:1087
Configure Proxy in Terminal#
Enter the following two commands in the command line
The macOS version of SS monitors the local HTTP port by default as 1087, while the Windows version is 1080. If you have changed the default port, use the port you specified.
This completes the process of bypassing the Great Firewall in the terminal. Of course, it is inconvenient to execute the command every time we want to bypass the firewall. So let's write the command into .bash_profile for future operations.
Add Proxy Configuration to .bash_profile#
If it hasn't been configured before, a new file will be created.
Go to .bash_profile and add the following code at the end
Enter the following command to make the configuration file take effect
Before using the proxy, check the current IP address
After that, enable the proxy and check again
When you don't need the proxy, execute proxy_off
to disable it
If you configure the environment variables in ~/.bash_profile
, but they don't take effect after restarting the terminal, you need to execute $source ~/.bash_profile
again.
I found that zsh loads the ~/.zshrc
file, and the .zshrc
file does not define any environment variables.
Solution:
At the end of the ~/.zshrc
file, add the following line:
source ~/.bash_profile
If it doesn't exist, create a file starting with .
in the home folder by pressing command
+shift
+.
.
Related Recommendations#
DDDD
Base64 aHR0cHM6Ly9iaXR6YXBwLnVrL2FmZj1VVU83YlRpbQ==