LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-29-2015, 09:32 AM   #1
linux_it_is
LQ Newbie
 
Registered: Jan 2015
Posts: 3

Rep: Reputation: Disabled
How to identify an Ephemeral port


Hi all,

I understand that Linux by default will limit its Ephemeral port allocation between 32768 to 61000.

I need to identify the applications running on my box (around 500 of them) which are intentionally using a port which happens to be in Ephemeral port range. Objective is to get a list of those apps and flag it so that the developers get to know of it and change their application port.

When I run netstat -nap to get a list of listen ports, I am unable to figure out if the port in Ephemeral range is actually allocated by OS or one of my apps has done it.


Thanks,
linux_it_is

Last edited by linux_it_is; 01-29-2015 at 09:36 AM.
 
Old 01-29-2015, 09:58 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,450

Rep: Reputation: 891Reputation: 891Reputation: 891Reputation: 891Reputation: 891Reputation: 891Reputation: 891
The file /etc/services should give you a list of the well known ports for services.

Linux will not allocate/use an ephemeral port if there is a process listening on it so as long as your developers don't listen on any of the "well known" ports they'll be fine.

(Actually they CAN listen on any of the well known ports, just be aware that if they do and you later decide to run a well known application then there will be a conflict. For example they could run their fongdaemon on port 80 if they wanted to but as soon as you want to install a web server........)
 
1 members found this post helpful.
Old 01-29-2015, 10:35 AM   #3
linux_it_is
LQ Newbie
 
Registered: Jan 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TenTenths View Post
The file /etc/services should give you a list of the well known ports for services.

Linux will not allocate/use an ephemeral port if there is a process listening on it so as long as your developers don't listen on any of the "well known" ports they'll be fine.

(Actually they CAN listen on any of the well known ports, just be aware that if they do and you later decide to run a well known application then there will be a conflict. For example they could run their fongdaemon on port 80 if they wanted to but as soon as you want to install a web server........)
Thanks TenTenths,

That's helpful for my wiki so that guys in future don't use these ports.

One of the usecase is for instance, my application acquires port 33000 and when linux is about to allocate the same port for ephemeral, OS checks that it is not free and moves on to perhaps 33001. Problem is some of our application are scheduled to be running in EMEA / APAC / NA time zones. So next day I can expect a scenario where application hardcoded to listen at 33000 is sleeping. OS find 33000 as free and allocates it, later when my app wakes up and tries to open a socket it fails. This is exactly what I want to address.

This is a scenario for a bank where I have hybrid environment and applications from different vendors / internal and all running and playing with the system. I have managed to sort 70 % of them such that they allocate port in the range of 31000-32000.

I was hoping netstat or perhaps some other utlility to tell me like the below port 49945 acquired by java app 21203 is actually a port given to him by OS. He did not hardcode it

tcp 0 0 0.0.0.0:49945 0.0.0.0:* LISTEN 21023/java

as against this app, which hardcoced it

tcp 0 0 0.0.0.0:13111 0.0.0.0:* LISTEN 4612/prod1

netstat output happens to be same for both instances

Common sense would say that 49945 looks like an ephemeral one and most likely given by OS. Apparently sometimes you are stcuk up in environment where common sense is not that common.

So any further help is much appreciated.

Thanks,
linux_it_is
 
Old 01-29-2015, 11:52 AM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,450

Rep: Reputation: 891Reputation: 891Reputation: 891Reputation: 891Reputation: 891Reputation: 891Reputation: 891
Change your ephemeral port range.

http://www.ncftp.com/ncftpd/doc/misc...rts.html#Linux
 
1 members found this post helpful.
Old 01-29-2015, 12:06 PM   #5
linux_it_is
LQ Newbie
 
Registered: Jan 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TenTenths View Post
Thanks Mate. Will work on to see what suits best for us
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I identify a physical USB-port? JZL240I-U Linux - Hardware 4 02-28-2014 02:17 AM
How to identify port number of USB drive? vipulmahajan Linux - Newbie 5 03-20-2012 01:29 AM
how to identify the status of serial port ("Port Already Opened") from a C program rajmohan_tricom Linux - Software 3 02-07-2010 10:27 PM
udevinfo - how do I uniquely identify the port a usb is on jjamesis Fedora 4 08-07-2007 08:31 AM
suse wont identify my ethernet port rbk25 Linux - Networking 5 06-20-2004 01:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration