LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-14-2010, 12:53 PM   #1
kzcom
LQ Newbie
 
Registered: Aug 2010
Posts: 25

Rep: Reputation: 0
get usage's bytes of a specific IP


Hi,
I need to get usage's bytes of a specific (src/dst)IP adress;can i use this
#iptables -L -n -v -x
with the other options that get only byte of the specefic IP address?
 
Old 09-14-2010, 03:10 PM   #2
goldenbarb
Member
 
Registered: Aug 2010
Distribution: Fedora, Centos, Debian
Posts: 49

Rep: Reputation: 7
Show us an example of your output.
 
Old 09-14-2010, 04:07 PM   #3
kzcom
LQ Newbie
 
Registered: Aug 2010
Posts: 25

Original Poster
Rep: Reputation: 0
This is a sample shell command:
#iptables -L TRAFFIC_ACCT -n -v -x
Chain TRAFFIC_ACCT (1 references)
pkts bytes target prot opt in out source destination
373 22687 all -- * * 192.168.1.2 0.0.0.0/0
101 44711 all -- * * 192.168.1.3

i want to send the bytes of 192.168.1.3 to a txt file.
i use the bellow command but it sends all of ips and usage bytes:
# iptables -L TRAFFIC_ACCT -n -v -x | awk '$1 ~ /^[0-9]+$/ { printf "IP: %s, %d bytes\n", $8, $2 }'
IP: 192.168.1.2, 22687 bytes
IP: 192.168.1.3, 44711 bytes
 
Old 09-14-2010, 04:16 PM   #4
goldenbarb
Member
 
Registered: Aug 2010
Distribution: Fedora, Centos, Debian
Posts: 49

Rep: Reputation: 7
Use grep or logical AND in awk.

Code:
iptables -L TRAFFIC_ACCT -n -v -x | grep '192.168.1.3' | awk '$1 ~ /^[0-9]+$/ { printf "IP: %s, %d bytes\n", $8, $2 }'

iptables -L TRAFFIC_ACCT -n -v -x |  awk '$1 ~ /^[0-9]+$/ && $8 ~ /192.168.1.3/ { printf "IP: %s, %d bytes\n", $8, $2 }'
 
1 members found this post helpful.
Old 09-15-2010, 02:43 AM   #5
kzcom
LQ Newbie
 
Registered: Aug 2010
Posts: 25

Original Poster
Rep: Reputation: 0
Thank you,it helped me.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Echo only text after a specific number of bytes genderbender Programming 3 09-01-2010 05:44 AM
IsThere a fridge, that we can program at specific date/time to unfreeze specific food frenchn00b General 3 07-21-2009 11:26 PM
How to force specific domain or user specific emails to proces in sendmail 8.13.5 FC5 peanutsa Linux - Newbie 1 03-22-2009 05:33 AM
Scanning memory range for specific bytes w/ GDB jrtayloriv Programming 5 03-17-2008 02:27 PM
TX bytes vs. httpd bytes ovrload Linux - Networking 3 10-12-2005 04:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration