linux利用windows的ccproxy软件实现网络代理上外网
场景
1、实验室Linux服务器无法上外网,使用麻烦,可利用windows本机的网络通过代理上网。
2、客户的Linux服务器无法连接外网,但是Linux可以ping通Windows的本机电脑,则可以在Windows本机开启ccproxy软件来代理上网。
解决方案:设置代理服务器
首先确保本机和服务器在同一局域网内,ping彼此的IP可以互相ping通,windows注意防火墙设置或直接关掉。
在Windows上,你可以使用以下软件来设置代理服务器:
- CCProxy:CCProxy是一个常用的代理服务器软件,它支持HTTP、HTTPS、FTP、SOCKS等协议,并提供了丰富的配置选项。
- WinGate:WinGate是一个功能强大的代理服务器和网关软件,它支持代理各种协议,并提供了许多高级功能,如防火墙、VPN支持等。
- Squid for Windows:Squid是一个流行的开源代理服务器,虽然它主要是为Linux和Unix系统设计的,但也有适用于Windows的版本。你可以使用Windows版的Squid来设置代理服务器。
- Fiddler:Fiddler是一个用于调试和监视HTTP流量的代理服务器软件。虽然它的主要用途是调试和分析Web应用程序,但它也可以用作代理服务器来转发和捕获HTTP流量。
下载安装软件ccproxy
注册:
1 2 3 4 | -- CCProxy无限用户版 序列号:JHEHIHCDDAHC 注册码:15f7f78febfaee55afeafefff7cb7fdfb3 |
ccproxy的设置
基本设置
只需要把其中最下面的选择本机局域网IP地址改为和服务器同一局域网内的IP,并打勾确认。
高级设置
在设置-》高级-》网络里,有一个禁止局域网外用户,默认勾选。取消勾选,否则不能网段的电脑不能代理,会报错“Auth Result: 禁止外部用户。”。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | [root@gp-master ~]# export all_proxy=http://100.10.211.199:808 [root@gp-master ~]# [root@gp-master ~]# curl www.baidu.com <html> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head> <body> <h1>Unauthorized ...</h1> <h2> IP Address: 100.11.11.73:24630<br> MAC Address: <br> Server Time: 2023-05-23 14:18:57<br> Auth Result: 禁止外部用户。 </h2> </body> </html> [root@gp-master ~]# curl www.baidu.com <!DOCTYPE html> <!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>关于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>©2017 Baidu <a href=http://www.baidu.com/duty/>使用百度前必读</a> <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a> 京ICP证030173号 <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html> [root@gp-master ~]# |
新建账户(可选)
点开账号
新建账户
服务器上设置代理
1 2 3 4 5 6 7 | export all_proxy=http://用户名:密码@本机局域网IP:ccproxy端口 # 例如 export all_proxy=http://rzc:passwd@10.123.3.121:808 -- 可以不用创建账号,直接配置代理 export all_proxy=http://10.123.3.121:808 |
ping命令无法走http代理,可以用conda/pip随便装个包试试,或者访问http服务。
总结
1、在设置-》高级-》网络里,有一个禁止局域网外用户,默认勾选。请取消勾选!!!
2、服务器直接配置:export all_proxy=http://100.123.3.121:808