Tech Tips

 in

—Kristofer Occhipinti

Three Steps to Find Your Total Download Bandwidth Usage

I have been working on bandwidth-monitoring of late, and I find the following three steps handy to find my download byte count. These steps use iptables, which is available with almost all distributions. It most likely already will be installed on your system (it is the basic firewall in Linux).

Steps one and two set up the monitoring, and step three allows you to view your download byte count. The first two steps need to be done only once (at boot time, if you want this available all the time). You need to run all the steps as root.

Step 1: create a chain:

$ iptables -N input_accounting

This creates an iptables chain named input_accounting.

Step 2: add a rule:

$ iptables -I INPUT -j input_accounting

This causes all incoming packets to “pass through” your newly created chain.

Step 3: start checking your bandwidth:

$ iptables -L -v | \
		grep input_accounting | \
		grep anywhere | \
       	awk '{ printf("%s\n", $2) }'

This should output your download byte count—for example, “500K”.

—Tanmay Mande

______________________

Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

Webcast
8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
On Demand
Moderated by Linux Journal Contributor Mike Diehl

Sign up and watch now

Sponsored by Skybot