Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Security
User Name
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.


  Search this Thread
Old 10-05-2009, 11:45 AM   #1
LQ Newbie
Registered: Sep 2007
Posts: 27

Rep: Reputation: 15
How to find out what port foreign ip is using


How can I find out what port is being used by a specific ip address? I often see a lot of traffic on one connection using iftop and I'd like to know more about it.

Old 10-05-2009, 12:11 PM   #2
Senior Member
Registered: Jan 2005
Location: Nottingham, UK
Distribution: Mageia 5, Linux Lite
Posts: 4,312

Rep: Reputation: 209Reputation: 209Reputation: 209
Netstat should help. I like to use netstat -tan. There's many other switches available. Type man netstat for a comprehensive list of arguments.
Old 10-05-2009, 01:06 PM   #3
Senior Member
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
You might eliminate the -a option (which will also include LISTENING state) and just use:
$ netstat -tn

You can get local program information (as root) with:
# netstat -tnp
Old 10-05-2009, 04:21 PM   #4
Registered: May 2001
Posts: 29,358
Blog Entries: 55

Rep: Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545
Netstat still requires a grep to narrow things down if you got pages of output. While not that intuitive for most the 'lsof' or 'fuser' may provide easier selectors. For example finding all local VNC ports: 'fuser -n tcp vnc' or all TCP/22 ports: 'lsof -Pnai tcp:22'. Note both take numerical ports as well as /etc/services type names (as in 'getent services portnumber').
Old 10-05-2009, 09:27 PM   #5
LQ Newbie
Registered: Jun 2009
Posts: 5

Rep: Reputation: 0
The fastest way is to use netstat -n with grep.


netstat -n | grep 999.999.999.999
No need to complicate things.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
find a port of a particular process ak.lokesh Linux - Newbie 1 03-19-2009 07:05 AM
specification of local and foreign ip addresses and port number for tcp adilturbo Linux - Networking 7 12-20-2006 05:20 AM
Using serial port card(PCMCIA) with IPAQ running Linux, can't find ttyS0 port d2army Linux - Laptop and Netbook 0 11-12-2005 08:07 PM
how do we find outbound port numbers mahanare Linux - Security 1 10-05-2004 12:32 PM
How to find out the port number fmohideen76 Linux - General 3 07-11-2002 08:18 AM > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 04:33 PM.

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