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-05-2009, 11:45 AM   #1
the_mulletator
LQ Newbie
 
Registered: Sep 2007
Posts: 27

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


Hi,

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.

Thanks
 
Old 10-05-2009, 12:11 PM   #2
{BBI}Nexus{BBI}
Senior Member
 
Registered: Jan 2005
Location: Nottingham, UK
Distribution: Mageia 6, KDE Neon
Posts: 4,313

Rep: Reputation: 212Reputation: 212Reputation: 212
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
anomie
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
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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
hackertarget
LQ Newbie
 
Registered: Jun 2009
Posts: 5

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

Quote:

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


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
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

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

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