Re: Finding TNS listener ports

  • From: "Gogala, Mladen" <gogala.mladen@xxxxxxxxx>
  • To: Sayan Malakshinov <xt.and.r@xxxxxxxxx>
  • Date: Wed, 29 Jul 2020 21:50:32 -0400

Hi Sayan!

Nmap will report what it finds in /etc/services. If there are multiple listener ports, each and every one of those ports should be listed in /etc/services. If they are not listed then there is no recourse but to dig through netstat output. The whole thing depend on the configuration. If TNS_ADMIN is centralized then there is only one listener.ora and it contains all the listeners. Even if there are many TNS_ADMIN directories, maintaining the /etc/services file should be a priority since it is a good system administration practice.

Regards

On 7/29/2020 8:34 PM, Sayan Malakshinov wrote:

Hi Mladen,

nmap thinks that only 1521 is an Oracle port, so in case of several listeners on different ports it can't determine real service behind them. For example, I have 2 different listeners on 1521 and 1522, but nmap returns only 1521 as an Oracle service. Moreover, by default nmap scans just the most common 1,000 ports for each protocol, so with default parameters it will not find 1522. The same thing with sshd - I reconfigured it to 1122 and nmap returns 'availant-mgr' for it.

On Thu, Jul 30, 2020 at 3:21 AM Mladen Gogala <gogala.mladen@xxxxxxxxx <mailto:gogala.mladen@xxxxxxxxx>> wrote:

    That is still much more cumbersome than nmap:

    [root@ora19c oracle]# nmap localhost|grep oracle
    1521/tcp open  oracle
    [root@ora19c oracle]#

    On 7/29/20 4:34 PM, Radoulov, Dimitre wrote:
    >
    > On Solaris I would use something like this:
    >
    > pgrep -lf '[t]nslsnr' |
    >   while read p x l x; do
    >     printf 'listener %s is listening on the following
    > interfaces/ports:\n' "$l"
    >     pfiles "$p" |
    >        nawk '/sockname: AF_INET / && !/0.0.0.0/ <http://0.0.0.0/> {
    >            _[$3] = $5
    >          } END {
    >          for (__ in _) print __, _[__]
    >          }'
    >   done
    >
    >
-- Mladen Gogala
    Database Consultant
    Tel: (347) 321-1217

    --
    //www.freelists.org/webpage/oracle-l




--
Best regards,
Sayan Malakshinov
Oracle performance tuning engineer
Oracle ACE Associate
http://orasql.org
--
Mladen Gogala

Oracle DBA

Tel: (347) 321-1217


Other related posts: