Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
02-12-2009, 04:30 AM
|
#1
|
Member
Registered: Feb 2009
Location: Ahmedabad, Gujarat, India
Posts: 197
Rep:
|
IPTables Show data transferred size in KB, MB
I have used IPTable rules to implement bandwidth usage on per IP per port base.....All things work fine......But when I put command
iptables -nvL
than it shows data transfered in bytes only....I want to see things in KB or MB what shud I do???
|
|
|
02-12-2009, 04:35 AM
|
#2
|
Member
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806
Rep:
|
are u sure as i do see traffic in MB and GB
|
|
|
02-12-2009, 04:41 AM
|
#3
|
Member
Registered: Feb 2009
Location: Ahmedabad, Gujarat, India
Posts: 197
Original Poster
Rep:
|
Yes sir, I am sure.......
See sir I am posting here the rules I have deployed
Just a min sir
|
|
|
02-12-2009, 04:46 AM
|
#4
|
Member
Registered: Feb 2008
Location: JHB South Africa
Distribution: Centos, Kubuntu, Cross LFS, OpenSolaris
Posts: 806
Rep:
|
It could be that the traffic that has matched those rules has not hit the MB levels yet
|
|
|
02-12-2009, 04:48 AM
|
#5
|
Member
Registered: Feb 2009
Location: Ahmedabad, Gujarat, India
Posts: 197
Original Poster
Rep:
|
iptables -A INPUT -s 192.168.1.0/10 -j sys
iptables -A INPUT -d 192.168.1.0/10 -j sys
iptables -A INPUT -s 10.10.135.0/24 -j sys_
iptables -A INPUT -d 10.10.135.0/24 -j sys_
I have developed two subchains sys and sys_
iptables -A sys -d 192.168.1.9
iptables -A sys -d 192.168.1.9 -p tcp --dport 80
iptables -A sys -d 192.168.1.9 -p tcp --sport 80
iptables -A sys -s 192.168.1.9
iptables -A sys -s 192.168.1.9 -p tcp --dport 80
iptables -A sys -s 192.168.1.9 -p tcp --sport 80
iptables -A sys_ -d 10.10.135.22
iptables -A sys_ -d 10.10.135.22 -p tcp --dport 80
iptables -A sys_ -d 10.10.135.22 -p tcp --sport 80
iptables -A sys_ -s 10.10.135.22
iptables -A sys_ -s 10.10.135.22 -p tcp --dport 80
iptables -A sys_ -s 10.10.135.22 -p tcp --sport 80
|
|
|
02-12-2009, 04:49 AM
|
#6
|
Member
Registered: Feb 2009
Location: Ahmedabad, Gujarat, India
Posts: 197
Original Poster
Rep:
|
But sir It is hitting to KBs...........
Should I try to make it in MB????
|
|
|
02-12-2009, 04:49 AM
|
#7
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
Quote:
Originally Posted by priyadarshan
iptables -A INPUT -s 192.168.1.0/10 -j sys
iptables -A INPUT -d 192.168.1.0/10 -j sys
iptables -A INPUT -s 10.10.135.0/24 -j sys_
iptables -A INPUT -d 10.10.135.0/24 -j sys_
I have developed two subchains sys and sys_
iptables -A sys -d 192.168.1.9
iptables -A sys -d 192.168.1.9 -p tcp --dport 80
iptables -A sys -d 192.168.1.9 -p tcp --sport 80
iptables -A sys -s 192.168.1.9
iptables -A sys -s 192.168.1.9 -p tcp --dport 80
iptables -A sys -s 192.168.1.9 -p tcp --sport 80
iptables -A sys_ -d 10.10.135.22
iptables -A sys_ -d 10.10.135.22 -p tcp --dport 80
iptables -A sys_ -d 10.10.135.22 -p tcp --sport 80
iptables -A sys_ -s 10.10.135.22
iptables -A sys_ -s 10.10.135.22 -p tcp --dport 80
iptables -A sys_ -s 10.10.135.22 -p tcp --sport 80
|
What is this? Some of these rules don't even have targets.
Could you post the actual output of "iptables -nvL", which is what you are having trouble with?
BTW, I'm moving this to Software, as it's not a security issue.
Last edited by win32sux; 02-12-2009 at 04:51 AM.
|
|
|
02-12-2009, 04:52 AM
|
#8
|
Member
Registered: Feb 2009
Location: Ahmedabad, Gujarat, India
Posts: 197
Original Poster
Rep:
|
Yes sir I did some mistakes while writing the things......But those rules are working properly......
The command
iptables -nvL is showing the packets as well as data transferred per IP as well as per post number.........but only in bytes..............
|
|
|
02-12-2009, 04:58 AM
|
#9
|
Member
Registered: Feb 2009
Location: Ahmedabad, Gujarat, India
Posts: 197
Original Poster
Rep:
|
pkts bytes targets prot opt in out source destination
258 44229 0 -- * * 0.0.0.0/24 10.10.135.22
These things come as output....
|
|
|
02-12-2009, 05:00 AM
|
#10
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
The content below the bytes column should indeed make use of "M" (or whatever) whenever needed. I assume there's a fixed cutoff point/policy for the switch to happen but I don't know what it is. For example, the box I'm using right now looks like:
Code:
win32sux@batcave:~$ sudo iptables -nvL
Chain INPUT (policy DROP 772 packets, 168K bytes)
pkts bytes target prot opt in out source destination
1270K 840M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
173 11290 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 1484K packets, 975M bytes)
pkts bytes target prot opt in out source destination
win32sux@batcave:~$
Last edited by win32sux; 02-12-2009 at 05:08 AM.
|
|
|
02-12-2009, 05:06 AM
|
#11
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
If the idea behind all of this is that you wish to use the command in a script, then maybe use the -x option in order to force all byte counters to be exact (in bytes) and then just have the script perform basic division in order to obtain KB/MB/GB/TB/etc.
|
|
|
02-12-2009, 05:16 AM
|
#12
|
Member
Registered: Feb 2009
Location: Ahmedabad, Gujarat, India
Posts: 197
Original Poster
Rep:
|
ok SIR.......
I too have tried iptables -nxvl but it shows the same.....
No probs.....
Now I am trying to make the data transfer till MBs so then I will see weather it works or not.......
Thanks............
|
|
|
02-12-2009, 05:19 AM
|
#13
|
Member
Registered: Feb 2009
Location: Ahmedabad, Gujarat, India
Posts: 197
Original Poster
Rep:
|
Sir I got it when I reached above 100 KB transfer thanks..........
|
|
|
02-12-2009, 05:27 AM
|
#14
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
If you want a command to check the count for a certain rule, try something like:
Code:
iptables -nvxL INPUT --line-numbers | grep ^2 | awk '{print $3/1024" KB"}'
This example would show you the count in kilobytes for the second rule of the INPUT chain. To get it to show megabytes just change the division and the text you want to be output:
Code:
iptables -nvxL INPUT --line-numbers | grep ^2 | awk '{print $3/1048576" MB"}'
Example of this approach in action on my box:
Code:
win32sux@batcave:~$ sudo iptables -nvxL INPUT --line-numbers | grep ^1
1 1271279 840970742 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
win32sux@batcave:~$ sudo iptables -nvxL INPUT --line-numbers | grep ^1 | awk '{print $3/1048576" MB"}'
802.012 MB
win32sux@batcave:~$
Last edited by win32sux; 02-12-2009 at 05:30 AM.
|
|
|
All times are GMT -5. The time now is 12:40 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|