Measuring traffic via IP Table

Reset Counter

iptables -Z && iptables -F

Set Monitoring Targets

iptables  -I INPUT 1 -s google.com -j ACCEPT
iptables  -I OUTPUT 1 -s google.com -j ACCEPT

…you may execute any operation here..

Read Counter

iptables -vn -L

Examples

root@kali:~# curl -L google.com

<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="zh-HK"><head><meta content="text
itemprop="image"><title>Google</title><script nonce="AK3K/fEpmkEbPwla7W5XVQ==">(function(){window.google={kEI
3,4,60,133,593,36,407468,722198,143,1197759,390,329118,1294,12383,4855,32692,15247,867,28684,364,3319,5505,83
36,3061,2,631,3240,8066,2883,21,317,4148,1,368,2778,520,399,992,1285,8,3767,597,11,14,423,856,2212,202,328,12
28,1284,16,84,336,81,2426,1639,607,474,1339,748,1039,3094,133,773,1548,525,6,728,592,1574,3195,199,1345,769,5
09,99,2,433,72,1408,123,279,297,943,127,1747,258,7,258,346,12,62,1096,8,276,2,1085,4,1461,659,408,162,64,27,3
2,80,1,900,896,1,8,1,2,2551,1,748,141,59,736,563,1,4265,1,1,1,1,3,7,128,338,57,12,46,27,33,10,4,4,1,2,2396506
fpdje';})();(function(){google.lc=[];google.li=0;google.getEI=function(a){for(var b;a&&(!a.getAttribute||!(b=
(b=a.getAttribute("leid")));)a=a.parentNode;return b};google.https=function(){return"https:"==window.location
){if(a=google.logUrl(a,b,e,c,g)){b=new Image;var d=google.lc,f=google.li;d[f]=b;b.onerror=b.onload=b.onabort=
...

root@kali:~# iptables -vn -L
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    4   744 ACCEPT     all  --  *      *       172.217.25.14        0.0.0.0/0

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  *      *       172.217.25.14        0.0.0.0/0