LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 03-03-2006, 01:30 PM   #1
cmptrguru7
LQ Newbie
 
Registered: Mar 2006
Posts: 4

Rep: Reputation: 0
Iptables command


I am wondering if anyone knows how to limit NAT Connections using iptables or some other command I have not thought of yet.

Basically if I have 10 users and I am using NAT I only want each user to be able to make say 100 NAT connections and if they exceed that say have 101 connections then their connection is either dropped until they fall below the limit or their connection is stopped until administratively restarted again or for a time limit.

Another way to look at this is how do I cap how many simultaneous connections a particular user on my network is able to make. Any help would be appreciated?
 
Old 03-03-2006, 01:53 PM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
Not sure about limiting connections, but I think you can do bandwidth limiting with IPtables. What exactly are you doing? Trying to limit torrents???
 
Old 03-03-2006, 01:57 PM   #3
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
There is a patch for netfilter for this called connlimit..

Visit www.netfilter.org and have a look at patch-o-matic.

You will need kernel sources and iptables sources to do this..
 
Old 03-03-2006, 01:58 PM   #4
cmptrguru7
LQ Newbie
 
Registered: Mar 2006
Posts: 4

Original Poster
Rep: Reputation: 0
I am also interested in bandwidth control. By preventing NAT connections I am trying to keep that one user with a virus on their computer from saturating the network and using up all the bandwidth. It could also be used to keep torrent and other p2p connections to a minimum. I have about 700 users and my total bandwith is a 10MB capped T3 line. I want all taffic to pass through the linux box to server as a firewall for one and also a control mechanisim to prevent all the bandwidth from being hogged by one user. I have written a firewall script and I am familar with some of the TC commands for bandwidth control, but any recommendations on this would be appreciative.
 
Old 03-03-2006, 02:02 PM   #5
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
Hi,

check the connlimit and connmark match extensions... they've been included in the recent kernels...
it's not specific to NAT connections, but if you use specific source and dest IPs, that shouldn't be too much of a problem.
Also, the following entries set the values used for all connections:
/proc/sys/net/ipv4/ip_conntrack_max
/proc/sys/net/ipv4/netfilter/ip_conntrack_*

In /proc/sys/net/ipv4, you also have lots of settings to strengthen your machine against floods and so on, have a look...

hope this helps !
 
Old 03-03-2006, 02:12 PM   #6
cmptrguru7
LQ Newbie
 
Registered: Mar 2006
Posts: 4

Original Poster
Rep: Reputation: 0
If I wanted to store connection tracking information in an external database like mysql qhat program would you recommend to do so. For example my table may have fields like:

SRC MAC, SRC IP, DEST IP, SRC Port, DEST Port, Protocol, Date/Time
 
Old 03-03-2006, 02:13 PM   #7
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
[edit: that doesn't apply to your last post but to the one before!]

tc is definitely the tool for QoS... i've been using it with HTB qdiscs, and it used to work fine (at some stage I was bored of not beeing able to use the net because of my flatmate downloading a *lot* with emule).
you can set your filters (to select which packets go in which queue) with iptables, but i believe i read somewhere that the implementation done in tc was more performant.

Last edited by fr_laz; 03-03-2006 at 02:24 PM.
 
Old 03-03-2006, 02:20 PM   #8
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
i don't know any soft doing that...
you can get this info by logging in iptables, but i'd be concerned about performance when doing that. Accessing the disk is really slow compared to networking, so i think you'd end up dropping lots of packets...
maybe parsing /proc/net/ip_conntrack may be a better way to do that. You don't have the MAC info though...
do you plan to have IDS on that machine? If yes, then Snort can log to a database... on Snort's website ( http://www.snort.org/docs/snort_htma...anual_2.4/rc1/ ), they explain all the different way to keep track of the info (writing to file, snmp, database...) and their adds and con.
 
Old 03-04-2006, 01:32 AM   #9
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
For logging options, use the -j ULOG target rather than just -j LOG

Then install the ulogd package.

man iptables & man ulogd for more info..
 
Old 03-06-2006, 10:08 AM   #10
cmptrguru7
LQ Newbie
 
Registered: Mar 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks for all the help I will take a look and see what I can come up with.
 
  


Reply



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
An error occured getting IPtables status from the command /etc/rc.d/init.d/iptables s CrazyMAzeY Linux - Newbie 10 08-12-2010 05:25 AM
iptables command/iptables GUI? basketkase999 Linux - Security 5 04-12-2005 02:43 PM
IPTABLES command netguy2000 Linux - Security 5 02-20-2004 09:02 AM
Iptables command ThePlague Linux - Networking 6 02-16-2004 04:51 PM
need iptables command for... di11rod Linux - Security 5 01-28-2004 04:34 PM

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

All times are GMT -5. The time now is 09:02 AM.

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