需求
现在有服务器134,135,137,138 四台服务器,134能上外网,其他的不能上外网,需要解决其他不能上外网的问题
前提
1)2个centos7服务器,其中192.168.129.221能上网,192.168.129.222不能上网
2)互相能ping通
实现
在221上安装tinyproxy软件
安装tinyproxy
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh epel-release-latest-7*.rpm
yum install tinyproxy
修改tinyproxy配置文件
vim /etc/tinyproxy/tinyproxy.conf
下图为端口,不需要修改,默认为8888
下图为修改后,箭头处修改的规则为:所有的IP都可以实用
开放8888端口
firewall-cmd --zone=public --add-port=8888/tcp --permanent
firewall-cmd --reload # 配置立即生效
启动tinyproxy服务
service tinyproxy start
service tinyproxy stop
service tinyproxy restart
检测服务是否启动
netstat -anp | grep 8888
本机测试
其中IP为221,IP为tinyproxy中
curl -x 192.168.129.221:8888 www.baidu.com
在222上关联代理
修改/etc/profile配置文件
在最后添加
http_proxy=http://192.168.129.221:8888 #ip为能上网的221,端口为默认的8888
https_proxy=$http_proxy
export http_proxy
export https_proxy
使配置生效
source /etc/profile
测试
curl www.baidu.com
未解决的问题
curl www.baidu.com可以,但是ping 不通
参考
安装tinyproxy
https://blog.csdn.net/qq_18598403/article/details/88227736
https://www.cnblogs.com/woodk/p/9815586.html
配置 https://www.cnblogs.com/chenglee/p/10154103.html
开放端口 https://www.cnblogs.com/heqiuyong/p/10460150.html
————————————————
版权声明:本文为CSDN博主「CBeann」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_37171353/article/details/109457413