I don't see MSSQL mentioned earlier and I missed the point about them being Gateway
as opposed to plain database listeners, but how about this suggestion:-
- Select a range of ports that are free
- Define them in /etc/services quoting the database name (DA, DB, DC, DD etc.)
- As the listener starts, it reads /etc/services and starts on a fixed port number, reporting failures however you choose, e.g. syslog, email, sms, console, 3rd party tools etc.
That way you know the ports should be allocated to just your service. If you start them at boot, then one would think that they should still be free. if something else is grabbing one, then find out why and/or change /etc/services
to move your service to a new port. It's not foolproof because not everything respects /etc/services
but it's a good place to start and many network tools (e.g. netstat
) do, making their output more meaningful.
You could even (if your databases are using a sequential naming system) make the port numbers obvious and predictable, e.g. DA is port 13001, DB is port 13002, etc. This would give your clients wanting to connect a consistent port to connect to.
Would that help?