Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On a server with several users I'm looking to reserve port ranges so that only one user has access to a specific port range, IE

user1: 2000-2005
user2: 2006,3003
user3: 1025

In doing so, an application spawned by that user can only access ports allotted to that user. All other ports would fail to bind. Is there a way to do this on a Linux (Ubuntu) server?

share|improve this question
add comment

1 Answer

I don't know if iptables owner module would help you, it will allow you to apply rules regarding the owner. You could do something like:

iptables -I OUTPUT -m owner --uid-owner=pmartinez -p tcp -m multiport --sports 2000:2005 -j ACCEPT
iptables -I OUTPUT -m owner --uid-owner=pmartinez -j REJECT

That won't avoid binding but it will block all traffic and only allow the specified ports.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.