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 03-29-2009, 02:05 AM   #1
divyashree
Senior Member
 
Registered: Apr 2007
Location: Bangalore, India
Distribution: RHEL,SuSE,CentOS,Fedora,Ubuntu
Posts: 1,386

Rep: Reputation: 135Reputation: 135
how to know about ports


How will I know which of my ports are opened and closed ????
 
Old 03-29-2009, 02:49 AM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by divyashree View Post
How will I know which of my ports are opened and closed ????
Run a port scanner such as nmap against your interface?
 
Old 03-29-2009, 02:50 AM   #3
centralb
LQ Newbie
 
Registered: Jan 2007
Distribution: Redhat, Debian, "Custom"
Posts: 27

Rep: Reputation: 15
Lightbulb

You can view listening ports as root with
Code:
netstat -apnt | less
You can view the number of open connections per IP with:
Code:
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
Both depend on your distribution.
 
Old 03-29-2009, 03:09 AM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by centralb View Post
You can view listening ports as root with
Code:
netstat -apnt | less
Keep in mind this won't show you the actual state of the ports. For example, the output of that command might tell me that I have something listening on port 80 when it is completely firewalled, thereby showing a state of "closed" to an actual port scanner. If you want to be sure, you need to scan from a separate box.

BTW, please remove the non-English parts from your signature, otherwise you are not complying with the LQ Rules. If you have any questions or comments about this matter, contact me via email. Do not use this thread.

Last edited by win32sux; 03-29-2009 at 03:12 AM.
 
Old 03-29-2009, 03:50 AM   #5
sigey
LQ Newbie
 
Registered: Feb 2009
Posts: 13

Rep: Reputation: 1
what i normally use on redhat is the handy command netstat --inet -a
ofcourse i think nmap is the most quick and easy way to do it.

thanks.
 
Old 03-29-2009, 03:51 AM   #6
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Usually I do 'nmap localhost'.
 
Old 03-29-2009, 04:56 AM   #7
divyashree
Senior Member
 
Registered: Apr 2007
Location: Bangalore, India
Distribution: RHEL,SuSE,CentOS,Fedora,Ubuntu
Posts: 1,386

Original Poster
Rep: Reputation: 135Reputation: 135
Thanks to all,I found my answer but how will I close my open ports,only by stopping the services or any method ????
 
Old 03-29-2009, 05:01 AM   #8
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by divyashree View Post
Thanks to all,I found my answer but how will I close my open ports,only by stopping the services or any method ????
Yes, you can either stop whatever service is listening on the ports, or you can set up a firewall.
 
Old 03-29-2009, 05:08 AM   #9
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by H_TeXMeX_H View Post
Usually I do 'nmap localhost'.
That's not gonna tell you what your ports look like to the bad guys, though.
 
Old 03-29-2009, 05:09 AM   #10
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by sigey View Post
what i normally use on redhat is the handy command netstat --inet -a
ofcourse i think nmap is the most quick and easy way to do it.
Again, the information provided by those two commands is completely different.

Neither of those command is a substitute for the other.
 
Old 03-29-2009, 05:42 AM   #11
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Quote:
Originally Posted by win32sux View Post
That's not gonna tell you what your ports look like to the bad guys, though.
Then use an online port scanner. Search google for them.
 
Old 03-29-2009, 06:11 AM   #12
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Those online port scanners are a good option. Although, personally, I just stick to nmap.

Last edited by win32sux; 03-29-2009 at 06:23 AM.
 
  


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
Need to block all ports and open only select ports on Ubuntu 7.1 Mr.J Linux - Networking 1 11-18-2008 02:45 AM
open ports for utorrent using iptables n close smpt to that ports shtorrent00 Linux - Networking 2 09-30-2008 03:34 PM
Problem opening ports - ports appear open, but do not work. computer_freak_8 Linux - Software 10 09-20-2008 09:39 PM
how? redirect apache2 outbound ports to specific ports w/iptables? nowshining Linux - Security 5 05-27-2008 02:46 AM
reject all ip & ports and allow only some ports with iptables ysar68 Linux - Security 1 05-12-2007 08:50 PM

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

All times are GMT -5. The time now is 01:09 PM.

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