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

Following up from an issue today, I have a question, possibly stupid, but here goes.

How can I block/prevent an application binding to a specific port? This pertains to linux/unix, but I'd be interested in NT as well.

I know I can prevent traffic using a firewall, and ports under 1024 require root, but I wasn't aware of a way to protect a port, only allowing a designated app to bind.

Is there a way?

Thanks

share|improve this question

2 Answers 2

up vote 3 down vote accepted

when you are on linux you can use selinux to accomplish this. you would create a port type for your application and add only the ports you would like your application to connect to. all other ports would generate an error message.

but be aware that selinux rules can get a bit nasty.

share|improve this answer

You don't mention whether it's one specific application you want to block, or any application.

To do it for any app, just have something bind to it before it starts. Netcat is your friend here. Assuming you want to block tcp/1234, your command would look something like: nc -lp 1234 > /dev/null will do what you want

share|improve this answer
    
Ok, I need to keep a port free for a given app, preventing any other app from taking it. –  Alex Jan 25 '10 at 22:06

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.