Re: Finding TNS listener ports

From: Mladen Gogala <gogala.mladen_at_gmail.com>
Date: Thu, 30 Jul 2020 17:10:00 -0400
Message-ID: <7ef9116c-8ec2-2351-4ab3-61df68998593_at_gmail.com>



As of Oracle 12c, there is the lreg process, new process which registers the instance against the local and remote listeners. That used to be done by pmon but is now done by lreg. If you are using 11.2 or earlier version, you are a sinner and should not be helped. Stop slouching and upgrade to 12c or newer! If, on the other hand, you were good, not only will Santa remember to bring you a present but you can also use the following:

-bash-4.2$ lsof -i4 -c tnslsnr|grep IPv4 ora_lreg_ 2180 oracle   11u     IPv4 28170      0t0       TCP ora19c.home.com:64344->ora19c.home.com:ncube-lm (ESTABLISHED)

The port is returned as "ncube-lm":

-bash-4.2$ grep ncube-lm /etc/services
ncube-lm        1521/tcp                # nCube License Manager
ncube-lm        1521/udp                # nCube License Manager
-bash-4.2$

Basically, lsof will return all "lreg" connections and you can look for them in the /etc/services to get the numeric ports.

On 7/29/20 10:04 PM, Tim Gorman wrote:
> Some 20 years ago, wrote this shell-script
> (http://evdbt.com/download/tnsprobe-sh/) named "tnsprobe.sh" to kind
> of brute-force search for TNS ports. Essentially, it tries each port
> in a specified range and tests it.
>
>
>
> On 7/29/2020 5: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_at_gmail.com <mailto:gogala.mladen_at_gmail.com>> wrote:
>>
>> That is still much more cumbersome than nmap:
>>
>> [root_at_ora19c oracle]# nmap localhost|grep oracle
>> 1521/tcp open  oracle
>> [root_at_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
>>
>> --
>> http://www.freelists.org/webpage/oracle-l
>>
>>
>>
>>
>> --
>> Best regards,
>> Sayan Malakshinov
>> Oracle performance tuning engineer
>> Oracle ACE Associate
>> http://orasql.org
>

-- 
Mladen Gogala
Database Consultant
Tel: (347) 321-1217


--
http://www.freelists.org/webpage/oracle-l
Received on Thu Jul 30 2020 - 23:10:00 CEST

Original text of this message