IP traffic

Hi there,

Is there a command line oneliner that will tell me current in and/or out traffic per IP not per device?
I love systat -ifstat. Is there a way to get that in batch mode per device and per IP?
 
Hello,

Maybe you can use [/file]vnstat[/file]

[CMD=]#pkg_add -rv vnstat[/cmd]
[CMD=]#mkdir /var/db/vnstat[/CMD]
[CMD=]#vnstat -u -i re0[/CMD]
[CMD=]#vnstat -l[/cmd]


Good luck!
 
diegoshaman said:
Hello,

Maybe you can use [/file]vnstat[/file]

[CMD=]#pkg_add -rv vnstat[/cmd]
[CMD=]#mkdir /var/db/vnstat[/CMD]
[CMD=]#vnstat -u -i re0[/CMD]
[CMD=]#vnstat -l[/cmd]


Good luck!

Thanks so much for the suggestion, I really want to do it without installing anything else. I read that bandwidthd uses libcap, not sure how to implement it though.
 
Try running
Code:
# ifconfig bge1
bge1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=8009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LINKSTATE>
	ether 00:30:05:9c:c7:6c
	inet 10.16.0.1 netmask 0xfffffc00 broadcast 10.16.3.255
	media: Ethernet autoselect (1000baseT <full-duplex>)
	status: active
# netstat -I bge1 -b
Name    Mtu Network       Address              Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll
bge1   1500 <Link#2>      00:30:05:9c:c7:6c 1469035719  7488     0 3134514787 991115044     0 2633373129     0
bge1   1500 10.16.0.0/22  10.16.0.1                0     -     -          0        0     -          0     -
# ifconfig bge1 inet 172.16.0.1/21 alias
# netstat -I bge1 -b
Name    Mtu Network       Address              Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll
bge1   1500 <Link#2>      00:30:05:9c:c7:6c 1471850230  7488     0  737768494 994197209     0 1515980821     0
bge1   1500 10.16.0.0/22  10.16.0.1                0     -     -          0        0     -          0     -
[color="Green"]bge1   1500 172.16.0.0/21 172.16.0.1               0     -     -          0        0     -          0     -[/color]
# ping -c 10 172.16.3.132
PING 172.16.3.132 (172.16.3.132): 56 data bytes
^C
--- 172.16.3.132 ping statistics ---
[color="Red"]7 packets transmitted[/color], 0 packets received, 100.0% packet loss
# netstat -I [color="DarkOrange"]bge1[/color] -b
Name    Mtu Network       Address              Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll
bge1   1500 <Link#2>      00:30:05:9c:c7:6c 1472404215  7488     0 1161194156 994757831     0 2047790783     0
[color="DarkOrange"]bge1[/color]   1500 10.16.0.0/22  [color="DarkOrange"]10.16.0.1[/color]                0     -     -          0        0     -          0     -
[color="DarkOrange"]bge1[/color]   1500 172.16.0.0/21 [color="DarkOrange"]172.16.0.1[/color]               0     -     -          0        [B][color="Red"]7     -        588     -[/color][/B]
netstat -I <iface> -b will give byte counters for each configured IP address of the interface. After that, using grep or awk through the results will give what you want.
 
Back
Top