firewalld+squid:如何设置代理

firewalld+squid:如何设置代理

IP xxxx 的基础设施服务器(没有互联网连接)执行以下请求:

$ wget http://google.com
--2016-11-04 09:32:55--  http://google.com/
Resolving google.com (google.com)... 172.217.22.110, 2a00:1450:4001:81d::200e
Connecting to google.com (google.com)|172.217.22.110|:8888... failed: Connection timed out.

代理服务器(squid 侦听 8888)具有以下接口: eth1: 1.1.1.1,其中来自基础服务器的所有传入请求均来自 eth2: 2.2.2.2,该接口具有默认路由 (80,443) 的互联网连接,因为其地址是翻译为防火墙(网关)

通过在代理服务器和 eth1(传入接口)上执行 tcpdump,我可以正确看到到达的流量:

09:49:10.033951 IP  x.x.x.x.45977 > 1.1.1.1.8888: Flags [S], seq 258250387, win 29200, options [mss 1460,sackOK,TS val 3204336400 ecr 0,nop,wscale 7], length 0
09:49:11.034310 IP  x.x.x.x.45977 > 1.1.1.1.8888: Flags [S], seq 258250387, win 29200, options [mss 1460,sackOK,TS val 3204337402 ecr 0,nop,wscale 7], length 0
09:49:13.042720 IP  x.x.x.x.45977 > 1.1.1.1.8888: Flags [S], seq 258250387, win 29200, options [mss 1460,sackOK,TS val 3204339408 ecr 0,nop,wscale 7], length 0
09:49:17.047283 IP  x.x.x.x.45977 > 1.1.1.1.8888: Flags [S], seq 258250387, win 29200, options [mss 1460,sackOK,TS val 3204343416 ecr 0,nop,wscale 7], length 0
09:49:22.303238 IP  x.x.x.x.45977 > 1.1.1.1.8888: Flags [R], seq 258250387, win 1400, length 0
09:49:25.060419 IP  x.x.x.x.45977 > 1.1.1.1.8888: Flags [S], seq 258250387, win 29200, options [mss 1460,sackOK,TS val 3204351424 ecr 0,nop,wscale 7], length 0
09:49:30.321096 IP  x.x.x.x.45977 > 1.1.1.1.8888: Flags [R], seq 258250387, win 1400, length 0

通过在代理服务器和 eth2(传出接口)上执行 tcpdump,我没有看到任何传出 http 流量

我在squid的配置中更改的只是以下内容:

acl infra-server src x.x.x.x/32
http_access allow infra-server
http_port 1.1.1.1:8888

就系统而言,SElinux 设置为宽容:

# getenforce
Permissive

以及firewalld的配置方式是:

# firewall-cmd --list-all --zone=internal
internal (active)
  interfaces: eth1
  sources: 
  services: dhcpv6-client ipp-client mdns samba-client ssh
  ports: 8888/tcp
  masquerade: no
  forward-ports: 
  icmp-blocks: 
  rich rules: 

# firewall-cmd --list-all --zone=external
external (active)
  interfaces: eth2
  sources: 
  services: http https ssh
  ports: 
  masquerade: yes
  forward-ports: 
  icmp-blocks: 
  rich rules: 

我只需要将流量从 eth1 转发到 eth2 的规则(我认为)。

相关内容