Monitoring Network Data over ports on Linux Red Hat 6.4

Aug - 06 2014 | By

No plugin needed

 

creates a script to see how much data was sent / received over ports in 1 minute

in this case ports 7000, 9160, 9042

The script creates a listener, waits for 1 min, prints the results then removes the listeners

Need to be super user (“su”) to run

change “eth1″ to your own network interface – can be retrieved via cmd “ifconfig”

 

iptables -A INPUT -i eth1 -p tcp –sport 7000 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp –sport 9160 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp –sport 9042 -j ACCEPT

iptables -A OUTPUT -o eth1 -p tcp –sport 7000 -j ACCEPT
iptables -A OUTPUT -o eth1 -p tcp –sport 9160 -j ACCEPT
iptables -A OUTPUT -o eth1 -p tcp –sport 9042 -j ACCEPT

iptables -Z INPUT
iptables -Z OUTPUT
sleep 60

iptables -vxL INPUT
iptables -vxL OUTPUT

iptables -D OUTPUT -o eth1 -p tcp –sport 7000 -j ACCEPT
iptables -D OUTPUT -o eth1 -p tcp –sport 9160 -j ACCEPT
iptables -D OUTPUT -o eth1 -p tcp –sport 9042 -j ACCEPT

iptables -D INPUT -i eth1 -p tcp –sport 7000 -j ACCEPT
iptables -D INPUT -i eth1 -p tcp –sport 9160 -j ACCEPT
iptables -D INPUT -i eth1 -p tcp –sport 9042 -j ACCEPT

Comments are closed. Please see front page on how to contact me