LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 12-14-2009, 04:52 PM   #1
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
Prevent port giving out.


I need to prevent some application to listen port.
So, when application executed it starts to listen port.
I want Linux, to ignore application port request.
How to prevent any applications to get a port or port for their usage.

Thanks
 
Old 12-14-2009, 05:34 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by nimnull22 View Post
I need to prevent some application to listen port.
What application? Why?


Quote:
Originally Posted by nimnull22 View Post
So, when application executed it starts to listen port.
I want Linux, to ignore application port request.
How to prevent any applications to get a port or port for their usage.
Here's some weak / strong options until you explain your situation details:
- if it's a fixed port bind something to the port beforehand ('nc'?),
- if it's a port below 1024 run the application from an unprivileged account,
- if it's a port below 1024 take away CAP_NET_BIND ('man capabilities'),
- run GRSecurity and the application under an account w/o port bind rights,
- run SE Linux and take out any port listening rules,
- run anything that intercepts the applications bind() system call,
- run the application as an isolated virtualization guest.
 
Old 12-14-2009, 05:54 PM   #3
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Original Poster
Rep: Reputation: 92
Quote:
Originally Posted by unSpawn View Post

What application? Why?
Because it is not "open source", and I do not know what to expect.

Quote:
Originally Posted by unSpawn View Post
Here's some weak / strong options until you explain your situation details:
- if it's a fixed port bind something to the port beforehand ('nc'?),
- if it's a port below 1024 run the application from an unprivileged account,
- if it's a port below 1024 take away CAP_NET_BIND ('man capabilities'),
- run GRSecurity and the application under an account w/o port bind rights,
- run SE Linux and take out any port listening rules,
- run anything that intercepts the applications bind() system call,
- run the application as an isolated virtualization guest.
Thank you, I have to check all of it.

It is port higher 1024 of course.

Last edited by nimnull22; 12-14-2009 at 05:58 PM.
 
Old 12-14-2009, 06:44 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You can use iptables to block any incoming calls to that port.
 
Old 12-14-2009, 08:15 PM   #5
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Original Poster
Rep: Reputation: 92
Quote:
Originally Posted by chrism01 View Post
You can use iptables to block any incoming calls to that port.
What about random port?
I just want to prevent an application to get one or any.
 
Old 12-15-2009, 02:20 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by nimnull22 View Post
Because it is not "open source", and I do not know what to expect.
Unless you add information we can actually use in replies I suggest virtualization.
 
Old 12-15-2009, 06:32 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Set your default Rule/Profile in iptables INPUT to drop, then only explicitly allow in the ones you expect.
That way, even if it (app) binds to a port, it won't get/see any incoming cxns.
 
Old 12-16-2009, 03:35 PM   #8
mejohnsn
Member
 
Registered: Sep 2009
Posts: 174

Rep: Reputation: Disabled
Quote:
Originally Posted by chrism01 View Post
Set your default Rule/Profile in iptables INPUT to drop, then only explicitly allow in the ones you expect.
That way, even if it (app) binds to a port, it won't get/see any incoming cxns.
Or, rather than trying to edit iptables rules himself, he could use 'ufw'. This program has a much simpler and more logical syntax, yet is flexible enough to do what he seems to want. It then edits the iptables rules for you.

One of the good decisions Canonical made was to put 'ufw' on all Ubuntu systems.

But the word 'seems' is key here: we really don't know what the OP wants, since he does not seem to understand the proper use of indefinite articles and quantifiers in English. Does he have in mind one specific application, which he does not want to allow to connect to any port? Or does he want to allow only a 'whitelist' of applications to connect to any port?

Whichever it really is, he should be able to figure out from the man page for 'ufw' how to do this -- unless he really is trying to do something impossible
 
Old 12-16-2009, 06:23 PM   #9
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Original Poster
Rep: Reputation: 92
Thanks for every one.

I found that iptables match OWNER is very useful.

If it is impossible to completely disable bind port for SOME application, I allow to go OUT only trusted programs.
Why "some", because it is not important which one, idea was to disable AT ALL. But looks like it is not easy.

Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SENDMAIL - How to prevent telnet into my server on port 25 adamrau Linux - Software 4 04-19-2010 07:17 PM
[ssh client]prevent to connect on every port exept one oudoubah Linux - Security 6 06-29-2007 11:48 AM
How to prevent X server from opening port 6000 glock19 Linux - General 5 05-23-2002 03:19 PM
How to prevent telneting to my mail server on port 25 adamrau Linux - Networking 7 10-24-2001 09:44 PM
How to prevent someone from telneting to my mail server on port 25 adamrau Linux - Security 2 10-11-2001 02:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 09:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration