Monday, 28 April 2014

SQUID SERVER WITH MIKROTIK CACHE HIT

Where 10.0.0.222 is the IP we assign to our server, and routing squid_route brand we use to bring traffic to our clients Squid.
× Very Important: Remove unnecessary masked IP – Firewall – NAT before activating the next rule.
  / Ip firewall mangle
add action = mark-routing chain = prerouting dst-port = 80 in-interface = LAN protocol = tcp new-routing-mark = squid_route
Where LAN is the name of the network interface of our customers, and squid_route is a routing mark we created earlier.
Two. Configured with Full Cache Squid
The well-known Full Cache, that will make all the content out of the hard drive of your server will run faster than the limit imposed to our customers. So while a customer can have 256kbps download limitation, with Full Cache we can make this very customer reach higher speeds without using internet.
  / Ip firewall mangle
 add action = mark-packet chain = forward dscp = 12 new-packet-mark = fullcache passthrough = no
Where the value 12 is the DSCP value used by default Squid to mark all outgoing traffic from the cache.
Once marked packages, we’ll just put it to use that mark, then proceed to configure the respective rule Queue Tree.
  / Queue tree
 add name = fullcache packet-mark = fullcache parent = global-out priority = 8 max-limit = 5M queue = default
Where 5M means the maximum speed that the items will leave the cache, and each can place limit it sees fit. If you do not want to have to have speed restriction or unlimited, then you would put the value 0.

MIKROTIK EVO – DSL LOADBALANCE

/ip address
add address=10.0.2.2/24 interface=wan2
add address=192.168.5.1/24 interface=Local
 
/ip firewall nat
add chain=srcnat out-interface=pppoe-out1 action=masquerade
add chain=srcnat out-interface=wan2 action=masquerade
 
/ip firewall mangle
add chain=prerouting in-interface=pppoe-out1 connection-state=new new-connection-mark=pppoe-out1_conn action=mark-connection passthrough=yes
add chain=prerouting in-interface=wan2 connection-state=new new-connection-mark=ether2_conn action=mark-connection passthrough=yes
 
add chain=output connection-mark=pppoe-out1_conn new-routing-mark=to_pppoe-out1 action=mark-routing passthrough=yes
add chain=output connection-mark=ether2_conn new-routing-mark=to_ether2 action=mark-routing passthrough=yes
 
/ip firewall mangle
add chain=prerouting in-interface=Local connection-state=new dst-address-type=!local per-connection-classifier=both-addresses:2/0 action=mark-connection new-connection-mark=pppoe-out1_conn passthrough=yes
add chain=prerouting in-interface=Local connection-state=new dst-address-type=!local per-connection-classifier=both-addresses:2/1 action=mark-connection new-connection-mark=ether2_conn passthrough=yes
 
add chain=prerouting in-interface=Local connection-mark=pppoe-out1_conn action=mark-routing new-routing-mark=to_pppoe-out1 passthrough=yes
add chain=prerouting in-interface=Local connection-mark=ether2_conn action=mark-routing new-routing-mark=to_ether2 passthrough=yes
 
/ip firewall mangle
 add chain=prerouting dst-address=10.0.2.0/24  action=accept in-interface=ether5
 
/ip route
add gateway=pppoe-out1 distance=1
add gateway=10.0.2.1 check-gateway=ping distance=2
 
/ip route
add gateway=pppoe-out1 routing-mark=to_pppoe-out1
add gateway=10.0.2.1 routing-mark=to_ether2 check-gateway=ping