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?


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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