Your Mikrotik Configuration will be:
Mark All HTTP Port 80 Traffic, so that we can use these Marked Packets in Route section.
/ip firewall nat
add action=accept chain=srcnat disabled=no dst-port=80 protocol=tcp
/ip firewall mangle
add action=mark-routing chain=prerouting disabled=no dst-port=80 new-routing-mark=http passthrough=yes protocol=tcp
Masquerade all traffic (Except http] on ether1 Only, which is connected with DSL Router. This is important to masquerade traffic on WAN Interface only, otherwise http packets will also be masqueraded with mikrotik ip.
add action=masquerade chain=srcnat disabled=no out-interface=ether1
Define Route for HTTP Marked packets, and set default rule for all other traffic, This is called policy base or pre traffic base routing
/ip route
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=10.0.0.2 routing-mark=http scope=30 target-scope=10
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=200.200.200.XXX scope=30 target-scope=10
(Where 10.0.0.2 is the Squid Proxy Server IP , and 200.200.200.XXx is our DSL Router IP or Fiber Connectivity)
That’s all for MIKROTIK, Now Mikrotik will Redirect HTTP Traffic to Squid Proxy via interface ether3. and all rest of traffic will be masqueraded/nat to WAN (ether1) which is connected with DSL or Optical Fiber Connectivity.
Now moving on to SQUID section .......
For example: (squid.conf)
#==============================
#Transparent Mode & Example ACL
#==============================
http_port 3128 transparent
acl mylocalnet src 0.0.0.0/0.0.0.0
http_access allow mylocalnet
and IPTABLES example:
DNAT port 80 request comming from LAN systems to squid 3128 aka transparent proxy
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 10.0.0.2:3128
###In this example, Squid proxy server have 2 Interface cards:
eth0: LAN (connected with Mikrotik’s PROXY INTERFACE ether3) = 10.0.0.2
eth1: WAN (connected with DSL Router or internet) = 200.200.200.203 / Default GW = 200.200.200.XXX / DNS = 200.200.200.XXX , 8.8.8.8
###It is necessary that SQUID can directly communicate with the users by setting ROUTE to communicate user subnet via mikrotik, otherwise it won’t be able to communicate with the user , Issue the following command :
route add -net 192.168.25.0 netmask 255.255.0.0 gw 10.0.0.1 dev eth0