Problen with transpartent proxy
Now i writing application on perl to calculate traffic on linux box using iptables. Your can download it from
Now it work :) It can calculate traffic for hosts and routers, many lists of dst/src networks may calculate separately,
Sorry docs now only in russian :(( for now
example can be download from
http://traffica.kiev.ua/download/traffica-1.9.b.3.tar.gz
but there is a problem "transparent proxy".
I have IPTABLES + SQUID transparent proxy.
==========================================
I need LOG all forward packets using -j LOG for billing reason.
I need have in the LOG address of a source. With out SQUID all ok! iptables -I FORWARD -j LOG
But after I have setup transparent proxy all source addresses changed to address of
my proxy server :((.
iptables -I OUTPUT -s ! 192.168.0.1 -j LOG
Show nothing :(
tcpdump -i eth0 not src host 192.168.0.1
Show all resuts ok like no transparent squid exists at all?
What should a do to protocol all sources with IPTABLES + transparent SQUID??
Quoted 2 lines · On Sat, Nov 01, 2003 at 11:46:44PM +0200, [email protected] wrote:
But after I have setup transparent proxy all source addresses changed to address of my proxy server :((.
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.
Quoted 2 lines
iptables -I OUTPUT -s ! 192.168.0.1 -j LOG
Show nothing :(
thos shows outgoing connections between proxy and server
Quoted 1 line
tcpdump -i eth0 not src host 192.168.0.1
May I assume that eth0 is your 'internal' interface (where the browers are located)? Then you see the connection between browser and proxy.
Quoted 2 lines
Show all resuts ok like no transparent squid exists at all?
What should a do to protocol all sources with IPTABLES + transparent SQUID??
LOG in INPUT.
btw: LOG is _NOT_ meant as an accounting mechanism, since it is way too slow for logging huge amoounts of packets. You should look into using ULOG / ulogd.
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
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
Quoted 3 lines
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 <nop,nop,timestamp 449824 12290142> (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?
Quoted 7 lines · On Sat, 1 Nov 2003 [email protected] wrote:
I need LOG all forward packets using -j LOG for billing reason.
I need have in the LOG address of a source. With out SQUID all ok! iptables -I FORWARD -j LOG
But after I have setup transparent proxy all source addresses changed to address of my proxy server :((.
Correct, and you need to be using the Squid access log for billing of the proxied traffic.
Somewhat related note: transparent interception of traffic is generally an evil hack and does break things. If possible the browsers should be configured to use the proxy for best functionality.
Regards
Henrik