Operating System - HP-UX
1820258 Members
2922 Online
109622 Solutions
New Discussion юеВ

How to reserve ports in /etc/services?

 
UNIX System Admins
Occasional Contributor

How to reserve ports in /etc/services?

I know that the /etc/services file can not be used for reserving ports, so how do you reserve ports for apps or DB that require certain ports? Ex.Our DBAs say that ports 7777, 4443, 7200 & 7001 need to be available for their apps to use. How can I keep something like MeasureWare from grabing one of those ports?
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor

Re: How to reserve ports in /etc/services?

The short answer is that you get there "firstest with the mostest". The first server to use the port gets it. You essentially make sure that none of the other services use it.

Check this listing: http://www.iana.org/assignments/port-numbers

The "proper" answer to your question is that you request an official registration of your service from IANA and then noone else is supposed to use it. Of course, you can guess how well that really works.
If it ain't broke, I can fix that.
Alex Lavrov.
Honored Contributor

Re: How to reserve ports in /etc/services?

You can reserve ports .... Every program that has permissions to bind to some port, will do it (if it's free now).

You can write some script that will tell you that someone took these ports and it's not the program you want, it will send you a message. You can use lsof:

lsof -i:


If you don't have lsof:
http://ftp.cerias.purdue.edu/pub/tools/unix/sysutils/lsof/binaries/hpux/

Alex.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
A. Clay Stephenson
Acclaimed Contributor

Re: How to reserve ports in /etc/services?

The really neat thing is that your DBA's have already chosen IANA assigned ports so THEY are breaking the rules.
If it ain't broke, I can fix that.
Kent Ostby
Honored Contributor

Re: How to reserve ports in /etc/services?

Un-assigned ports can be used via the /etc/services file.

HOWEVER, if you happen to use one without it being officially registered, you could be in trouble later when an officially registered product comes along and you want both products on the same system.

I recall this happening when ServiceGuard came out originally. Some application was using ports that it had not reserved and SG used those ports as well. It led to the application having to be fixed and recompiled.

"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"