Linux – How to block an application binding to a port (all OSs)

iplinuxnetworkingport

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

Best Answer

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.

Related Topic