一千萬個為什麽

搜索

如何讓我的客戶端(主機)在Docker容器中使用我的Squid代理?



As an Example, I have 1 client (IP: 192.168.0.200) and 1 host (IP: 192.168.0.15). If client want to connect to the internet, then in host will be created container which contains squid proxy (I pull form the sameersbn/squid:latest`)

我創建容器的語法是:

docker run -d -net None --name SQUID_192.168.0.200 -p 9001:3128 -v /home/administrator/container-data:/var/log/squid3

在我的客戶端配置IP如下:

auto enp0s3
iface enp0s3 inet static
地址192.168.0.200
netmask 255.255.255.0
gateway 192.168.0.15

然後我使用iptables將數據包從192.168.0.200轉發到容器

iptables -t nat -A PREROUTING -p tcp -i wlp3s0 -s 192.168.0.200 --dport 9001

這是我的問題:

  1. I don't know better use -net None or -net Host or something else
  2. I do not know if my way is right or not, to direct the packet form 192.168.0.200 to container name SQUID_192.168.0.200 (I'm tried using port 9001:3128)
  3. I have tried to access internet from the client, I opened google.com and detik.com, but it's not recorded in access.log

轉載註明原文: 如何讓我的客戶端(主機)在Docker容器中使用我的Squid代理?

一共有 0 個回答: