wget代理的设置

来源:互联网 发布:win7 映射网络驱动器 编辑:程序博客网 时间:2024/05/01 06:59

小白今天执行wgt一个命令:

<linux101 [wsj] :/home/wsj>  wget -T 5 -t 1 http://10.137.1.120:7580/wsj/bond.jsp--2013-11-27 10:20:18--  http://10.137.1.120:7580/wsj/bond.jspResolving proxycn.china.com... 17.10.5.20Connecting to pproxycn.china.com|17.10.5.20|:8080... connected.Proxy request sent, awaiting response... Read error (Connection timed out) in headers.Giving up.


这样一个报错,小白于是又开始左左右右的寻找根因,发现肯定是在哪里设置了一个代理,在业务的各个层次目录下查找没找到,然后在系统配置的层面上查找,发现在/etc/wgetrc中有这么一行:

# You can set the default proxies for Wget to use for http and ftp.
# They will override the value in the environment.
http_proxy = proxycn.china.com:8080

将标红处注释掉,重新执行wget命令,就可以了:

<linux101 [wsj] :/home/wsj>  wget -T 5 -t 1 http://10.137.1.120:7580/wsj/bond.jsp--2013-11-27 10:02:06--  http://10.137.1.120:7580/wsj/bond.jspConnecting http://10.137.1.120:7580/wsj/bond.jsp... connected.HTTP request sent, awaiting response... 200 OKLength: 410 [text/html]Saving to: `bond.jsp.1'100%[======================================================================================>] 410         --.-K/s   in 0s


吐舌头

扩展:

1. 创建wget代理:

方法一: 在/etc/wgetrc中添加 http_proxy = proxycn.china.com:8080这样的语句(当然这个代理不需要用户名和密码验证)

方法二: 创建用户的~/.wgetrc文件中,添加如下内容:

http_proxy = http://proxy.server.com:8080/
ftp_proxy = http://proxy.server.com:8080/
--proxy-user=username
--proxy-passwd=mypasswd

两种方法执行后需要source,立即生效。

2. 为什么设置代理

a. 代理的机制

A机需要B机的数据,A直接与C机建立连接,C机接收到A机的数据请求后,与B机建立连接,下载A机所请求的B机上的数据到本地,再将此数据发送至A机,完成代理任务,这里C为代理服务器。

b. 代理的作用

1)共享网络--使得内网可以上外网,还能监控网络和记录传输,加强局域网的安全性,管理用户(小白的公司就因为这个原因设置了代理)。

2)加快访问网站速度--在网络出现拥挤或故障时,可通过代理服务器访问目的网

3)隐藏自己的真实地址信息,还可隐藏自己的IP---防止被黑客攻击,或者或者黑客攻击时隐藏自己

4)突破网络限制---比如网站服务器发生故障,可以利用代理查询到一些快照信息,不至于什么都查不到