Hi,
I don't have a good example at hand, but there sure had been reports in the past from people who were unable to connect to their 11g databases using sqlplus because of using localhost.localdomain in the TNS listener configurations. Apparently, the solution was to replace the localhost.localdomain entry with the actual hostname or IP and adding it to the /etc/hosts file. There seems to be a general consensus that the host name in the listener.ora file must not be localhost.localdomain in order for Oracle to be able to accept remote connections.
I have never experienced such problem and was never able to reproduce it. Why should my listener configuration and using localhost.localdomain be any problem for remote computers trying to connect? From what I understand, the Oracle Listener will listen for incoming connections on all available interfaces, not just localhost or 127.0.0.1, which of course cannot be accessed from another computer.
Please see below example. I'm using localhost.localdomain and tnslnr is clearly listening on all interfaces for connections (:::1521). I have no problems to connect to the database (11gR2 XE) using SQL Developer from another machine.
Can someone perhaps explain it? Was this behavior perhaps different in the past? Was it a matter of Oracle database version, IPv4 or 6?
The examples below are from Oracle Linux 7, running XE, but I experience the same results on OL 5/6 using 11g EE and 12c. No problems connecting from a remote system.
Thanks!
Solution:
https://docs.oracle.com/cd/B28359_01/network.111/b28317/listener.htm#NETRF008
If the user specifies a host name for the HOST
parameter in the ADDRESS line of the listener.ora
file, the listener listens on IN_ADDRANY
in case the host name is default host name. If the user wants the listener to listen on the first IP to which the specified host name resolves, the address must further be qualified with (IP=FIRST)
.
In other words, if the host entry in the listener.ora file is localhost.localdomain, and the machine hostname is also localhost.localdomain, the listener will listen for incoming connections on all interfaces and therefore accept remote connections. If the host entry is localhost, but the machine name is not, the listener will not accept remote connections.
---------
[root@localhost ~]# ss -nlpt | grep 1521
LISTEN 0 128 :::1521 :::*
users:(("tnslsnr",pid=14653,fd=10))
[oracle@localhost admin]$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[oracle@localhost admin]$ cat listener.ora
# listener.ora Network Configuration File:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)