Go Back   The macosxhints Forums > OS X Help Requests > Networking



Reply
 
Thread Tools Rate Thread Display Modes
Old 01-23-2002, 12:33 AM   #1
albockiole
Prospect
 
Join Date: Jan 2002
Location: Boston
Posts: 10
determining ports that are in use

There was a similar post earlier about blocking a port over a LAN, but how can you find out which ports are in use, so you can block the offending port?

I seem to remember reading somewhere that there was a program you could run in the terminal that would report what ports were in use (and could also refresh at a user-defined interval), but I can't remember what that program is.

Anyone out there know how I can determine what ports are in use on my computer?

thanks in advance...
albockiole is offline   Reply With Quote
Old 01-23-2002, 01:35 AM   #2
blb
All Star
 
Join Date: Jan 2002
Location: CO, USA
Posts: 908
netstat -nf inet will show all current connections, TCP and UDP. netstat -anf inet will add listening ports to this; basically, the LISTEN port is where a server (or daemon) is sitting, waiting for a connection.

If you want to know which process is listening to a port, use lsof. For example:

Code:
$ netstat -anf inet
...
tcp        0      0  127.0.0.1.1033         *.*                    LISTEN
so I want to know who's listening on port 1033, I'd use lsof:

Code:
$ sudo lsof -i :1033
...
netinfod    207 root    6u  inet 0x01a9cd1c      0t0  TCP localhost:1033 (LISTEN)
(the interesting one being the LISTEN state again, the others are currently connected). In this case, 1033 is the NetInfo daemon (netinfod).
blb is offline   Reply With Quote
Old 01-23-2002, 05:13 AM   #3
Gwyrrdin
Prospect
 
Join Date: Jan 2002
Location: Leeuwarden/ The Netherlands
Posts: 21
this is what I use

this command works great....

Read the manpage for more options...
Code:
% lsof -i -n -P
Gives a very complete overview of all your networkconnections.

Good Luck

Gwyrrdin
__________________
OS X= Beauty with Brains!
Gwyrrdin is offline   Reply With Quote
Old 01-25-2002, 12:35 PM   #4
albockiole
Prospect
 
Join Date: Jan 2002
Location: Boston
Posts: 10
Thanks for the tips everyone...

It turns out the program I wanted to block is using a random port everytime it starts up, so it's making it very difficult to do so.

Oh well, at least I know how to take care of the static ones.

Thanks...
albockiole is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 06:47 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.