You are not logged in.

#1 2016-01-14 07:28:40

prazola
Member
Registered: 2015-11-23
Posts: 26

Squid on a dedicated server - Transparency

Hi, I was enjoying squid in my lan when I realized that it broke the bandwidth limiter of my router.
The limiter uses the original clients IP to know what to do and squid hide every IP.
So I decided to set it to transparent, but I can't make it work.

I'm in a single 192.168.0.0/23 LAN.
Gateway + DNSMASQ at 192.168.0.1
Squid server with two eth adapter:

enp0s13: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.1.2  netmask 255.255.254.0  broadcast 192.168.1.255
        ether 00:00:5a:9d:d4:a0  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 18  

enp0s18: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1470
        inet 192.168.0.4  netmask 255.255.254.0  broadcast 192.168.1.255
        inet6 fe80::213:d4ff:fe38:7f4f  prefixlen 64  scopeid 0x20<link>
        ether 00:13:d4:38:7f:4f  txqueuelen 1000  (Ethernet)
        RX packets 411  bytes 37835 (36.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 282  bytes 34611 (33.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

This is my config:

#                                                                                                     
# Recommended minimum configuration:                                                                  
#                                                                                                     
                                                                                                      
# Example rule allowing access from your local networks.                                              
# Adapt to list your (internal) IP networks from where browsing                                       
# should be allowed                                                                                   
#acl localnet src 10.0.0.0/8    # RFC1918 possible internal network                                   
#acl localnet src 172.16.0.0/12 # RFC1918 possible internal network                                   
acl localnet src 192.168.0.0/23 # RFC1918 possible internal network                                   
#acl localnet src fc00::/7       # RFC 4193 local private network range                               
#acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines                    
                                                                                                      
acl SSL_ports port 443                                                                                
acl Safe_ports port 80          # http                                                                
acl Safe_ports port 21          # ftp                                                                 
acl Safe_ports port 443         # https                                                               
acl Safe_ports port 70          # gopher                                                              
acl Safe_ports port 210         # wais                                                                
acl Safe_ports port 1025-65535  # unregistered ports                                                  
acl Safe_ports port 280         # http-mgmt                                                           
acl Safe_ports port 488         # gss-http                                                            
acl Safe_ports port 591         # filemaker                                                           
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT

###
#delay_pools 1
#delay_class 1 2
#delay_access 1 allow  all
#delay_parameters 4 32000/32000 8000/8000 600/64000 16000/16000
###

#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager
#forwarded_for on

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 8080 transparent
visible_hostname squid.amd64.home
#http_port 3128 transparent
#http_port 80 intercept

#forwarded_for truncate

# Uncomment and adjust the following to add a disk cache directory.
range_offset_limit 2 GB
maximum_object_size 2 GB
cache_dir ufs /mnt/squid 58000 16 256
cache_mem 128 MB
maximum_object_size_in_memory 512 KB
cache_replacement_policy heap LFUDA
range_offset_limit -1
quick_abort_min 16 KB
# Leave coredumps in the first cache dir
coredump_dir /mnt/squid/



# MS UPDATES
refresh_pattern -i microsoft.com/.*\.(cab|exe|ms[i|u|f]|[ap]sf|wm[v|a]|dat|zip) 4320 80% 43200 reload-into-ims
refresh_pattern -i windowsupdate.com/.*\.(cab|exe|ms[i|u|f]|[ap]sf|wm[v|a]|dat|zip) 4320 80% 43200 reload-into-ims
refresh_pattern -i windows.com/.*\.(cab|exe|ms[i|u|f]|[ap]sf|wm[v|a]|dat|zip) 4320 80% 43200 reload-into-ims

# PACMAN
refresh_pattern \.pkg\.tar\.   0       20%     4320      reload-into-ims
refresh_pattern -i .(deb|rpm|exe|zip|tar|tgz|bz2|ram|rar|bin|xz|pkg|apk)$ 4320 80% 13200
refresh_pattern \.tar\.xz\. 0   20%     4320    reload-into-ims
#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
#refresh_pattern .              0       20%     4320
#refresh_pattern \.pkg\.tar\.   0       20%     4320      reload-into-ims
refresh_pattern .              0       20%      4320

cache_effective_user squid

I want to use enp0s18 to access internet and enp0s13 to serve clients how can I do this? I'm not good at networking and I really need help with iptables.
Every idea is welcome.

Offline

#2 2016-01-14 09:59:07

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: Squid on a dedicated server - Transparency

prazola wrote:

...that it broke the bandwidth limiter of my router.
The limiter uses the original clients IP to know what to do and squid hide every IP.
So I decided to set it to transparent, but I can't make it work.

Transparent or not, the proxied traffic will still originate from the proxy server so the router will still only see the IP address of the squid host.

Offline

#3 2016-01-14 10:28:50

prazola
Member
Registered: 2015-11-23
Posts: 26

Re: Squid on a dedicated server - Transparency

Thank you for the info, but how can I solve this, if I can?

Last edited by prazola (2016-01-14 10:29:08)

Offline

#4 2016-01-14 10:31:11

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: Squid on a dedicated server - Transparency

You can't - if the traffic is going through the proxy then the router will see the traffic coming from that IP. There's no (sane way of) getting around that.

squid itself is capable of applying rate-limiting; I'm not familiar enough with that feature to be able to help though sorry.

Offline

#5 2016-01-14 10:40:43

prazola
Member
Registered: 2015-11-23
Posts: 26

Re: Squid on a dedicated server - Transparency

I've read something about delays, but can they limit only the "squid to internet" bandwidth without compromise on "clients to squid"? Thank you.

Offline

#6 2016-01-14 14:06:35

prazola
Member
Registered: 2015-11-23
Posts: 26

Re: Squid on a dedicated server - Transparency

Partially solved, this is the code for per-ip download bandwidth limit.

acl group288 src 192.168.0.87/32 192.168.0.89/32 192.168.0.88/32 192.168.0.56/32
acl group656 src 192.168.0.61/32 192.168.0.95/32 192.168.0.112/32
acl group1024 src 192.168.0.92/32
delay_pools 3
delay_class 1 1
delay_class 2 1
delay_class 3 1
delay_parameters 1 288000/307200
delay_parameters 2 525000/630000
delay_parameters 3 819200/870400
delay_access 1 allow group288
delay_access 2 allow group656
delay_access 3 allow group1024
delay_access 1 deny all
delay_access 2 deny all
delay_access 3 deny all

Now, how to limit UPLOAD? smile

Offline

Board footer

Powered by FluxBB