linux代理上网5分钟搞定
云服务中只有一台可以访问外网,另外几台都没有外网ip。如何让其他机器能够访问外网
1. 代理机器:可以访问外网的机器
利用goproxy 安装配置非常简单https://github.com/snail007/goproxy/blob/master/README_ZH.md#%E8%87%AA%E5%8A%A8%E5%AE%89%E8%A3%85
#安装 curl -L https://raw.githubusercontent.com/snail007/goproxy/master/install_auto.sh | bash #启动 proxy http -t tcp -p "0.0.0.0:38080" --daemon
2. 需要访问外网的机器
vim /etc/profile 添加
vim /etc/profile
#内网机器不能上网需要配置个代理
http_proxy=172.18.142.251:38080 https_proxy=$http_proxy ftp_proxy=$http_proxy no_proxy=172.18.142.*,*.local,localhost,127.0.0.1 export http_proxy https_proxy ftp_proxy no_proxy [work@xyz ~]$ source /etc/profile #即可
git配置代理:
[work@xyz ~]$ cat /home/work/.ssh/config Host gitee.com HostName gitee.com User git Port 22 ProxyCommand nc --proxy 172.18.142.251:38080 %h %p
[work@xyz ~]$chmod 600 /home/work/.ssh/config
配置完成,可以curl测试一下,这个代理不能ping通。
此处参考https://www.jianshu.com/p/05e3a2959efe
但是goproxy 有个问题
非注册版本自动版本检查退出
建议换成tinyproxy
https://blog.csdn.net/shorile/article/details/79020927
tinyproxy nc 支持有问题,所以git的代理走https的 tinyproxy没问题
转载:https://whatua.com/2019/05/19/linux%E4%BB%A3%E7%90%86%E4%B8%8A%E7%BD%915%E5%88%86%E9%92%9F%E6%90%9E%E5%AE%9A/