您的位置:首页 > 其它

各种代理设置方法

2011-11-20 15:13 288 查看
在实验室需要通过代理上网,所以经常遇到需要设置代理达情况,不管是用apt安装软件还是编写程序,。

1,设置apt-get的代理(unbuntu系统):

These are three methods of using apt-get with a http-proxy.


Temporary proxy session

This is a temporary method that you can manually use each time you want to use apt-get through a http-proxy. This method is useful if you only want to temporarily use a http-proxy.
Enter this line in the terminal prior to using apt-get (substitute your details for yourproxyaddress and proxyport).

export http_proxy=http://yourproxyaddress:proxyport



APT configuration file method

This method uses the apt.conf file which is found in your /etc/apt/ directory. This method is useful if you only want apt-get (and not other applications) to use a http-proxy permanently.


 On
some installations there will be no apt-conf file set up. This procedure will either edit an existing apt-conf file or create a new apt-conf file.
gksudo gedit /etc/apt/apt.conf


Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).

Acquire::http::Proxy "http://yourproxyaddress:proxyport";


Save the apt.conf file.


BASH rc method

This method adds a two lines to your .bashrc file in your $HOME directory. This method is useful if you would like apt-get and other applications for instance wget, to use a http-proxy.

gedit ~/.bashrc


Add these lines to the bottom of your ~/.bashrc file (substitute your details for yourproxyaddress and proxyport)

http_proxy=http://yourproxyaddress:proxyport
export http_proxy


Save the file. Close your terminal window and then open another terminal window or source the ~/.bashrc file:
source ~/.bashrc


Test your proxy with sudo apt-get update and whatever networking tool you desire. You can use firestarter or conky to see active connections.
If you make a mistake and go back to edit the file again, you can close the terminal and reopen it or you can source ~/.bashrc as shown above.
source ~/.bashrc



How to login a proxy user

If you need to login to the Proxy server this can be achieved in most cases by using the following layout in specifying the proxy address in http-proxy. (substitute your details for username, password,
yourproxyaddress and proxyport)

http_proxy=http://username:password@yourproxyaddress:proxyport
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息