如何设置RouterOS在另一台机器上使用Web代理?

RouterOS文档展示了如何通过内置在RouterOS中的HTTP代理透明地代理所有的networkingstream量:

/ip firewall nat add in-interface=ether1 dst-port=80 protocol=tcp action=redirect to-ports=8080 chain=dstnat /ip proxy set enabled=yes port=8080 

我想在另一台机器上运行一个代理,这样我就可以利用Squid等更复杂的过滤规则。 但是,如果我使用NAT将stream量redirect到运行Squid的另一台计算机,则不起作用,因为HTTP请求需要重写才能成为代理HTTP请求; 只是redirectstream量给了鱿鱼不好的请求错误。

不需要在RouterOS中设置代理。 您可以直接通过NAT将所有传出的HTTPstream量路由到服务器:

 ip firewall nat add in-interface=eth1 src-address=!<IP of Squid machine> dst-port=80 protocol=tcp action=dst-nat to-addresses=<IP of Squid machine> to-ports=8080 

当squid机器与其他机器通过相同的接口通信时,需要最后一个参数“src-address =!…”。 否则,它会像这样:

  1. 计算机发送HTTP请求
  2. RouterOS将这个数据包发送给squid
  3. Squid发送HTTP请求到networking服务器
  4. RouterOS将squid请求再次发送到squid – > loop

它可以通过parent-proxy设置完成:

 /ip proxy set parent-proxy=<IP of Squid machine> parent-proxy-port=3128 
 /ip proxy set parent-proxy=<IP of Squid machine> parent-proxy-port=3128 /ip firewall nat chain=dstnat src-address=!<IP of Squid machine> protocol=tcp dst-port=80 src-address-list=<IP of Local machine> action=redirect to-ports=8080