Hi everyone.
I have four computer running behind a linux machine which is sharing the
internet access using NAT. I'd like to write some iptables rules that count
the number of bytes that go from the eth0 on the linux machine (internet
interface) to the individual IP addresses (via eth1). I'd also like to count
the number of outgoing internet bytes from each machine.
Can somebody please get me started in the right direction?
I am also running a transparent proxy and if possible, would like to count
the traffic going through that as well.
Here is my current (simple) firewall script.
EXTIP=`ifconfig eth0 | awk /eth0/'{next}//{split($0,a,":");split(a[2],a,"
");print a[1];exit}'`
# Enable masquerading
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to $EXTIP
echo 1 > /proc/sys/net/ipv4/ip_forward
# Secure it
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state NEW -i ! eth0 -j ACCEPT
iptables -P INPUT DROP
iptables -A FORWARD -i eth0 -o eth0 -j DROP
iptables -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
thanks in advance.