Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
allow only one incoming tcp connection from a source IP?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
pahud
Tux's lil' helper
Tux's lil' helper


Joined: 26 Nov 2002
Posts: 103

PostPosted: Wed Feb 26, 2003 1:59 pm    Post subject: allow only one incoming tcp connection from a source IP? Reply with quote

I have a daemon listening on tcp port 2235 and I'd like restrict that
every client can only has 1 active inbound tcp connection to this socket.
Is it possible to control the limit by iptables? I know there are limit and iplimit modules availabe but they don't fits my requirement. Any example or URL is highly welcome here. :P
Back to top
View user's profile Send private message
pahud
Tux's lil' helper
Tux's lil' helper


Joined: 26 Nov 2002
Posts: 103

PostPosted: Wed Feb 26, 2003 2:36 pm    Post subject: Reply with quote

Simply to say, something like
Code:
per_source =1

in xinetd
But I wish to deploy this with iptables.
idea?
Back to top
View user's profile Send private message
rtn
Guru
Guru


Joined: 15 Nov 2002
Posts: 427

PostPosted: Wed Feb 26, 2003 3:44 pm    Post subject: Reply with quote

Check out this iptables module in the kernel:

Connections/IP limit match support

--rtn
Back to top
View user's profile Send private message
pahud
Tux's lil' helper
Tux's lil' helper


Joined: 26 Nov 2002
Posts: 103

PostPosted: Thu Feb 27, 2003 12:24 am    Post subject: Reply with quote

rtn wrote:
Check out this iptables module in the kernel:

Connections/IP limit match support

--rtn


Well, you mean something list this?
Code:
# iptables -I INPUT -p tcp --dport 6666 -m limit --limit
1/s -j allowed


I am afraid the client can have more than 1 tcp connection to tcp:6666
in the first second or even have 1 connection every second, that is to say,
10 connectoins after 10 seconds.

Idea? :roll:
Back to top
View user's profile Send private message
pahud
Tux's lil' helper
Tux's lil' helper


Joined: 26 Nov 2002
Posts: 103

PostPosted: Thu Feb 27, 2003 7:51 am    Post subject: Reply with quote

I think I found the solution

Code:

iptables -A INPUT -p tcp  --dport 80 -s xxx.xxx.xxx.xxx -m iplimit
--iplimit-above 1 -j  REJECT
iptables -A INPUT -p tcp --dport 80 -s xxx.xxx.xxx.xxx -j ACCEPT
iptables -P INPUT DROP


When the first connection comes, it will bypass the first rule and
match the 2nd rule. When the 2nd connection comes while the 1st is still
connected, it will match the 1st rule and hence rejected.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum