Configuring Internet proxy for Unix and Linux

  
        

The company's network environment is a bit complicated, and the damn "secure policy" requires all external connections to be implemented through HTTP proxies. In the Win environment, it is only necessary to synchronize the proxy configuration through the domain policy, but it is relatively troublesome for Linux. Study it and share it with everyone.


Get proxy server address

There are several ways to set the general proxy. It is relatively simple to see directly in the network configuration of IE. Whether it can be modified or not, at least the configuration of the IP/hostname and port number can be seen. This is enough!

The other one is automatically obtained as shown in the figure below. This is relatively necessary. The brain is gone.


Open a terminal in advance, type netstat, don't press Enter, and immediately switch to IE to access a relatively slow web page. Cut back the terminal and press Enter! Then & hellip; & hellip;

 C: Usersliqunjia & gt; netstatActive Connections Proto Local Address Foreign Address State TCP 10.239.204.38:5357 GUANQUNW-MOBL: 60787 TIME_WAIT TCP 10.239.204.38:54912 outlooksh: 59532 ESTABLISHED TCP 10.239.204.38: 59490 fmscsp1fe04: 5061 ESTABLISHED TCP 10.239.204.38:59678 outlooksh: 59532 ESTABLISHED TCP 10.239.204.38:59842 litrin-test: http TIME_WAIT TCP 10.239.204.38:59844 litrin-test: http TIME_WAIT TCP 10.239.204.38:59847 litrin-test: http TIME_WAIT TCP 10.239.204.38:59848 litrin-test: http TIME_WAIT TCP 10.239.204.38:59850 litrin-test: http TIME_WAIT TCP 10.239.204.38:59851 litrin-test: http TIME_WAIT TCP 10.239.204.38:59857 litrin-test: http TIME_WAIT TCP 10.239.204.38:59858 litrin-test:http TIME_WAIT TCP 10.239.204.38:59862 litrin-test:http TIME_WAIT TCP 10.239.204.38:5986 7 shzdmzpr02_int: 911 ESTABLISHED TCP 10.239.204.38:59869 shmdmzpr02_int: 911 CLOSE_WAIT TCP 10.239.204.38:59870 shmdmzpr02_int: 911 ESTABLISHED TCP 10.239.204.38:59871 shmdmzpr02_int: 911 ESTABLISHED TCP 10.239.204.38:59872 shmdmzpr02_int: 911 ESTABLISHED TCP 10.239.204.38: 59873 shmdmzpr02_int: 911 ESTABLISHED TCP 10.239.204.38:59874 shmdmzpr02_int: 911 ESTABLISHED TCP 10.239.204.38:59875 shmdmzpr02_int: 911 ESTABLISHED TCP 10.239.204.38:59876 shmdmzpr02_int: 911 ESTABLISHED TCP 10.239.204.38:59877 shmdmzpr02_int: 911 ESTABLISHED TCP 10.239.204.38: 59878 shmdmzpr02_int: 911 ESTABLISHED TCP 10.239.204.38:59879 shmdmzpr02_int: 911 ESTABLISHED TCP 10.239.204.38:59880 shmdmzpr02_int: 911 ESTABLISHED TCP 127.0.0.1:50035 LIQUNJIA-MOBL: 62522 ESTABLISHED TCP 127.0.0.1:62522 LIQUNJIA-MOBL: 50035 ESTABLISHED TCP [::1]:59671 LIQUNJ IA-MOBL: 59673 ESTABLISHED TCP [::1]: 59673 LIQUNJIA-MOBL: 59671 ESTABLISHED

A large number of established points to the same port, this ip and port are the proxy address.

Desktop Environment

The main thing here is the configuration of Firefox, which is no different from the FF configuration under Windows.


Configuration under Shell

I think that under normal circumstances, few people can browse the web just by shell. In most cases, the shell's Internet connection is only used for Use wget/curl or update manager.

The Internet proxy settings under the shell are mainly implemented through the configuration of several environment variables. The format is as follows:

export http_proxy=http://server-ip:port/#HTTPProxy Configuration export https_proxy=https://server-ip:port/#httpsProxy Configuration export ftp_proxy=ftp: //server-ip:port/#ftpproxy (can you be older?)export no_proxy=*.edu #Do not pass the proxy address feature

It should be noted that if your proxy is user-authenticated, The format of the configuration should look like this:

export http_proxy=http://username:password@server-ip:port/

Well, if you have a username or password, ” @””/” Symbols such as —— For example, Windows domain account authentication methods mostly have this problem, you can use the ”” symbol to escape.

If you don't want to enter the proxy configuration every time you log in, you can save the export command to ~/.bashrc (or other shellrc), and the system will load automatically each time you start the shell. .

wget actually can directly specify the proxy server authentication method, you can also use the – no_proxy parameter to forcibly bypass the proxy.

wget --proxy-user=USER --proxy-password=PASS http://www.abc.com/wget --no_proxy http://www.abc.com/#没有代理

Curl is naturally more flexible than wget.

curl --proxy http(s)://server-ip:port http://abc.com/#Specify a separate proxy curl --socket4 server-ip:port http://abc. Com/#specify socket4 proxy curl --socket5 server-ip:port http://abc.com/#specify socket5 proxy curl --proxy-user username:password http://abc.com/#使用系统代理服务Configure curl --noproxy http://abc.com # bypass the proxy
Copyright © Windows knowledge All Rights Reserved