天天看點

linux使用tinyproxy代理上網需求前提實作未解決的問題參考

需求

現在有伺服器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 

linux使用tinyproxy代理上網需求前提實作未解決的問題參考

下圖為修改後,箭頭處修改的規則為:所有的IP都可以實用

linux使用tinyproxy代理上網需求前提實作未解決的問題參考

開放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
           
linux使用tinyproxy代理上網需求前提實作未解決的問題參考

本機測試

其中IP為221,IP為tinyproxy中

curl -x 192.168.129.221:8888 www.baidu.com
           
linux使用tinyproxy代理上網需求前提實作未解決的問題參考

在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 不通

linux使用tinyproxy代理上網需求前提實作未解決的問題參考

參考

安裝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