On Saturday 06 September 2003 01:28, C3 wrote:
> The script runs ok now. thanks 
>
> But there are a couple of problems. The main one being that traffic is
> not counted by the clients when their web browsers are not set to use a
> proxy, since they are being put through my transparent proxy. The only
> way I can get traffic to count is to specify to use my ISP's proxy server
> (which I don't want to do because they charge for all traffic through
> it).
The behavior was according your original description (at
least as I understood it). It is no problem to change this,
though.
> Since outgoing requests on port 80 from the clients are all redirected to
> port 8080 on my server with iptables, would there be a way to write some
> sort of rule that basically says "count any incoming traffic on eth0 as
> part of the IP address on the local network that sent the request"?
>
> This is a tough one!
>
> The other problem is minor in comparison: traffic to/from the server
> isn't counted (i.e. when I log into the server and use lynx, the byte
> counters for 192.168.0.1 do not change)
This is not possible because the login- and the http-connection
are independent connections.
The easiest is to count the traffic entering and leaving your
internal interface. However this is not entirely correct with
respect to your second problem, but it is as closely as you
can get.
The accounting-part of the script should look like:
# Setup accounting Rules
#
# account traffic to this host and the outbound traffic
# to the Internet per IP
#
$IPT -t mangle -A PREROUTING -i eth1 --src <IP1> -j RETURN
same rule for other remaining IP addrs
# account traffic from this host and the inbound traffic
# from the Internet per IP
#
$IPT -t mangle -A POSTROUTING -o eth1 --dst <IP1> -j RETURN
same rule for other remaining IP addrs
# Secure it
#
# allow incoming connections from internal net to this host
$IPT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A INPUT -m state --state NEW -i ! eth0 -j ACCEPT
# allow incoming connections from internal net passing to
# the Internet, and the corresponding traffic back
#
$IPT -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A FORWARD -m state --state NEW -i ! eth0 -j ACCEPT
$IPT -t nat -A PREROUTING -i eth1 -p tcp -s 192.168.0.0/24 \
-d ! 192.168.0.0/16 --dport 80 -j REDIRECT --to-port 8080
BTW: This only works with kernel 2.4.18 and later.
Ciao, Horst
--
»When pings go wrong (It hurts me too)« E.Clapton/E.James/P.Tscharn