LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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
 
LinkBack 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 3 / CrunchBang Linux 10 Statler / Easy Peasy
Posts: 4,293

Rep: Reputation: 205Reputation: 205Reputation: 205
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, FreeBSD
Posts: 3,925
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: 26,518
Blog Entries: 51

Rep: Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598Reputation: 2598
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


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 08:04 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration