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 10-19-2005, 05:49 PM   #1
metallica1973
Senior Member
 
Registered: Feb 2003
Location: Washington D.C
Posts: 2,190

Rep: Reputation: 60
properly closing ports


What is the best way to close udp and tcp ports. I ran nmap against my system at home running SUSE 9.0 and iptables and it came up with a couple of ports that I had concerns about. I wanted to know why is it that one day I will run a port scan and it will say that a majority of my ports are closed and another day it will say open:filtered and how do I closed ports that appear to be open. Here is a snippet from the nmap scan for different days:

october 15 - 2005

5716/udp closed prosharerequest
5717/udp closed prosharenotify
6000/tcp open X11
6110/udp closed softcm
6111/udp closed spc
7649/udp closed cucme-2
7650/udp closed cucme-3
7651/udp closed cucme-4
8080/tcp open http-proxy
9535/udp closed man
9876/udp closed sd
10080/udp closed amanda
38293/udp closed landesk-cba
39213/udp open|filtered sygatefw

port 6000 X11 ?
port 392113 open ?

october 17 - 2005

27960/udp open|filtered quake3
28910/udp open|filtered heretic2
31335/udp open|filtered Trinoo_Register
31337/udp open|filtered BackOrifice
32768/udp open|filtered omad
32770/udp open|filtered sometimes-rpc4
32771/udp open|filtered sometimes-rpc6
32772/udp open|filtered sometimes-rpc8
32773/udp open|filtered sometimes-rpc10
32774/udp open|filtered sometimes-rpc12
32775/udp open|filtered sometimes-rpc14
32776/udp open|filtered sometimes-rpc16
32777/udp open|filtered sometimes-rpc18
32778/udp open|filtered sometimes-rpc20
32779/udp open|filtered sometimes-rpc22
32780/udp open|filtered sometimes-rpc24

why is one day saying open:filtered and other days it is saying closed?
 
Old 10-19-2005, 08:07 PM   #2
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
Hi
Filtered tells you that a firewall is not telling you whether it is opened or not.
It can be open or closed.
So I guess sometimes your firewall is ON, sometimes it is not..
if you want to know which application opens a port, use
lsof | grep IP

And the best way to close a port is to kill the application that opens it.

Last edited by nx5000; 10-19-2005 at 08:09 PM.
 
Old 10-19-2005, 08:16 PM   #3
int0x80
Member
 
Registered: Sep 2002
Posts: 310

Rep: Reputation: Disabled
If this truly is your system, then you may want to wipe it and install with updated versions of everything. You may have been owned, repeatedly. Keep your applications updated, and consider using a kernel patch such as grsecurity.

In regards to your question, the proper way to deny (external) access to a port is to use a firewall such as iptables. Using 31337/udp as an example:

iptables -A INPUT -i eth0 -p udp --dport 31337 -j DROP
 
Old 10-19-2005, 09:43 PM   #4
metallica1973
Senior Member
 
Registered: Feb 2003
Location: Washington D.C
Posts: 2,190

Original Poster
Rep: Reputation: 60
what would use X11 on port 6000? Is that a remote control program port for X windows.

P.S

many thanks to your responses!
 
Old 10-19-2005, 11:44 PM   #5
tkedwards
Senior Member
 
Registered: Aug 2004
Location: Munich, Germany
Distribution: Opensuse 11.2
Posts: 1,549

Rep: Reputation: 52
Quote:
32779/udp open|filtered sometimes-rpc22
32780/udp open|filtered sometimes-rpc24

why is one day saying open:filtered and other days it is saying closed?
UDP is a connectionless protocol which means that packets are 'fire-and-forget', ie. the app on the other end may not respond, even if it has received the packets correctly. So open|filtered means that the port is either open and accepting connections or closed and dropping packets - in other words you can't tell which one it is by doing a port scan. closed would usually mean that a firewall is blocking it and sending back a packet notifying that it has blocked you.

Its normal for X to listen on that port, many distros don't disable it listening for connections by default. If I were you I'd just install something like firestarter, guarddog or shorewall and use them to configure your firewall.

BTW you can see which programs are listening on which ports with
Code:
netstat -nlp
as root.
 
Old 10-20-2005, 04:45 PM   #6
metallica1973
Senior Member
 
Registered: Feb 2003
Location: Washington D.C
Posts: 2,190

Original Poster
Rep: Reputation: 60
I am just having trouble understanding why one day my nmap scans are saying everything is closed but the ports that I have allowed in and the next day there are saying that they are opened and filtered. That is very confusing and backwards. Netfilter has some bugs. My firewall is either blocking the ports and closed and have open ports but filtered to only allow certain traffic through so why are there these inconsistencies when scanning my firewall. My current version of iptables is iptables v1.2.8
 
Old 10-20-2005, 05:48 PM   #7
tkedwards
Senior Member
 
Registered: Aug 2004
Location: Munich, Germany
Distribution: Opensuse 11.2
Posts: 1,549

Rep: Reputation: 52
I'm not sure why it'd do that either, but I doubt its a bug in iptables. Its used in millions of computers around the world and a bug that big would have long since been noticed and fixed (that's not to say there aren't bugs in iptables of course).

If you're like me and you find those iptables scripts hard to read and don't trust yourself to get them right I'd definately install shorewall or firestarter and use those to configure iptables. Then try rescanning the machine.
 
Old 10-21-2005, 06:07 PM   #8
metallica1973
Senior Member
 
Registered: Feb 2003
Location: Washington D.C
Posts: 2,190

Original Poster
Rep: Reputation: 60
I truly appricate all of your help thanks.
 
Old 10-22-2005, 09:50 AM   #9
ravee
Member
 
Registered: Jan 2005
Location: India
Distribution: Fedora Core 2
Posts: 83

Rep: Reputation: 15
Quote:
I will run a port scan and it will say that a majority of my ports are closed and another day it will say open:filtered and how do I closed ports that appear to be open.
Maybe you are not saving the iptables rules to a file. To make the rules persistent across reboots. For that you use the command:
# iptables-save > filename

And you have to enter a line in the /etc/rc.d/rc.local (for redhat - for debian it is different file) :

iptables-restore < filename

That will load your rules back to memory at time of booting.

There is a interesting article at
http://linuxhelp.blogspot.com/2005/1...ewall-for.html

Hope this helps.
 
Old 10-22-2005, 12:28 PM   #10
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
metallica1973,

You're not running nmap against localhost are you?
 
Old 10-23-2005, 02:04 PM   #11
metallica1973
Senior Member
 
Registered: Feb 2003
Location: Washington D.C
Posts: 2,190

Original Poster
Rep: Reputation: 60
No, I am running nmap from work to my home server. Can you please explain the difference. I know that when you ping the local host from inside you network your are going to see applications listening in the inside and that can be very confusing. Is that correct?

Last edited by metallica1973; 10-23-2005 at 02:09 PM.
 
  


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
Closing Ports Murdock1979 Linux - Security 1 09-23-2005 09:44 AM
Closing ports??? NCC-1701&NCC-1701-D Linux - Security 6 05-29-2005 09:23 AM
Closing these ports... greygoose80 Slackware 2 12-19-2004 11:12 PM
closing ports azi Linux - Security 5 12-07-2003 09:33 AM
CLOSING PORTS Stephanie Linux - Security 9 05-23-2001 12:11 PM

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

All times are GMT -5. The time now is 11:56 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