From: Subject: Re: Problen with transpartent proxy Date: Sun, 2 Nov 2003 22:24:59 +0200 (EET) Sender: netfilter-devel-admin@lists.netfilter.org Message-ID: <1104.192.168.0.241.1067804699.squirrel@192.168.0.1> References: <1464.192.168.0.240.1067723204.squirrel@192.168.0.1> <20031102172736.GG1536@sunbeam.de.gnumonks.org> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-u Content-Transfer-Encoding: 8bit Cc: Return-path: To: In-Reply-To: <20031102172736.GG1536@sunbeam.de.gnumonks.org> Errors-To: netfilter-devel-admin@lists.netfilter.org List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: List-Id: netfilter-devel.vger.kernel.org Let me explain algorithm of my billing. I use -j LOG only for debug reason The target of my program is billing The main fiche is calculation for many network list FOR EXAMLE My client IP is 192.168.0.214 `$net_id' defined in config file or SQL database networks type A (0$/1G ) zz.xx.cc.vv/bb ............ aa.ss.dd.ff/gg networks type B (25$/1G) hh.jj.kk.ll/vv ............ tt.yy.uu.ii/oo All other networks (15$/1G) ========================= iptables -t mangle -I FORWARD -s 192.168.0.214 -j MARK --set-mark 0x2 iptables -t mangle -I FORWARD -d 192.168.0.214 -j MARK --set-mark 0x3 1) Calculating total client traffic counter for client `192.168.0.214' iptables -t mangle -A FORWARD -d zz.xx.cc.vv/bb -j MARK --set-mark ($netID * 4) iptables -t mangle -A FORWARD -s zz.xx.cc.vv/bb -j MARK --set-mark ($netID * 4 + 1) iptables -t mangle -A FORWARD -d aa.ss.dd.ff/gg -j MARK --set-mark ($netID * 4) iptables -t mangle -A FORWARD -s aa.ss.dd.ff/gg -j MARK --set-mark ($netID * 4 + 1) Traffic or all client for `networks type A ($netID=1)' iptables -t mangle -A FORWARD -d hh.jj.kk.ll/vv -j MARK --set-mark ($netID * 4) iptables -t mangle -A FORWARD -s hh.jj.kk.ll/vv -j MARK --set-mark ($netID * 4 +1 ) iptables -t mangle -A FORWARD -d tt.yy.uu.ii/oo -j MARK --set-mark ($netID * 4) iptables -t mangle -A FORWARD -s tt.yy.uu.ii/oo -j MARK --set-mark ($netID * 4 +1 ) Traffic or all client for `networks type B ($netID=2)' iptables -t mangle -m mark -A FORWARD -s 192.168.0.214 --mark ($netID * 4) -j MARK --set-mark ($net_id*4+2) iptables -t mangle -m mark -A FORWARD -d 192.168.0.214 --mark ($netID * 4 + 1 ) -j MARK --set-mark ($net_id*4+3) traffic for client `192.168.0.214' network A ($netID=1) iptables -t mangle -m mark -A FORWARD -s 192.168.0.214 --mark ($netID * 4) -j MARK --set-mark ($net_id*4+2) iptables -t mangle -m mark -A FORWARD -d 192.168.0.214 --mark ($netID * 4 + 1 ) -j MARK --set-mark ($net_id*4+2) traffic for client `192.168.0.214' network B ($netID=2) I can read counter from STDIN (iptables -t mangle -x -L, iptables-save -c) or one of the perl modules. All calculation Ok and results is same is Cisco netflow, until transparent proxy was enabled :(((( ========================= Yes eth0 is my `LAN' interfase (192.168.0.1) eth1 is my internet interfase > of course. IT is a _proxy_ after all. you have two totally seperate > connections, one between browser and proxy, and the other one between > proxy and server. I understand when user write in the browser `my proxy is 192.168.0.1:3128' There is NO way to calculate traffic for different lists of networks AS etc.. accept parsing LOG of my proxy server! But when proxy working in TRANSPARENT mode and on client side no proxy exist in the browser config??? May be there is way to look for the source of the packets generated by proxy ? In `tcpdump -i eth0' i can see source addresses of the real host where client browsing: 23:25:10.276818 > MP1.intelserv.kiev.ua.1084 > www-1.southbury.ibm.com.www: . 341:341(0) ack 1393 win 31856 (DF) I believe IPTABLES can do this! For OUT packet i have found solution for the transparent proxy just change FORWARD to PREROUTING. may bee conntrack some module can help?