Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have an RHEL 6 system which has 20 users. I have 20 ports on which separate versions of a service is running. I want user a to access port a, but not other ports. Is there a way to do this? (possibly by modifying iptables)?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

You can use the "owner" iptables module to do this. As an example to restrict port 999 to the user 'fred' only you can use:

iptables -I OUTPUT -p tcp --dport 999 -j REJECT
iptables -I OUTPUT -p tcp --dport 999 -m owner --uid-owner fred -j ACCEPT

The above rules are inserted to the top of the OUTPUT chain so the order reject then accept.

share|improve this answer

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.