Oracle and Firewalls On Windows UNIX
Oracle and Firewalls On Windows UNIX
Oracle and Firewalls On Windows UNIX
x,
8.1.x
PURPOSE
-------
To explain, how Sql*Net 2.x/Net8 works and can be configured to work through
a firewall.
OR
mts_dispatchers="(address=(protocol=tcp)(host=xxx)(port=2500))(dispatchers=1)"
mts_dispatchers="(address=(protocol=tcp)(host=xxx)(port=2600))(dispatchers=1)"
In the above example, the firewall must be configured to open TCP/IP ports
2500 and 2600.
III / Oracle8/8i (8.x) - Unix: Firewall without Network Address Translator (NAT)
---------------------------------------------------------------------------
1 - In dedicated server mode, Unix natively implements TCP/IP sharing, so
there should be no problem with connectivity.
2 - For MTS mode, you may configure MTS to use specific TCP/IP ports e.g.:
mts_dispatchers="(address=(protocol=tcp)(host=xxx)(port=2700))(dispatchers=1)"
mts_dispatchers="(address=(protocol=tcp)(host=xxx)(port=2800))(dispatchers=1)"
In the above example, the firewall must be configured to open TCP/IP ports
2700 and 2800.
OR
you may install and configure Connection Manager (CMAN) provided natively
as part of Net8 from Net8 (8.0.3) onwards.
IV / Oracle8 (8.x) - Unix: Firewall with Network Address Translator (NAT)
------------------------------------------------------------------------
1 - In dedicated server mode, Unix natively implements TCP/IP sharing, so
there should be no problem with connectivity.
2 - In MTS mode, you may configure Connection manager (CMAN).
V / Oracle7 (7.x) - Windows NT: Firewall without Network Address Translator (NAT)
-------------------------------------------------------------------------
There is no solution other than to use a sqlnet proxy such as a firewall.
VI / Oracle8 (8.x) - Windows NT: Firewall without Network Address Translator (NAT)
-------------------------------------------------------------------------
Unlike Unix, Windows does not implement TCP/IP port sharing by default.
When using either dedicated or MTS mode, registry parameter USE_SHARED_SOCKET=TRUE
may be set in the Windows registry. The location of the parameter varies and
depends on the Oracle version. For registry location details, refer
[NOTE:124140.1],
which also discusses other methods to set the parameter.
VII / Oracle8 (8.x) - Windows NT: Firewall with Network Address Translator (NAT)
-------------------------------------------------------------------------
1 - In dedicated server mode, set registry parameter USE_SHARED_SOCKET=TRUE.
2 - In MTS mode, you may either configure Connection manager (CMAN)
OR
ADDITIONAL INFORMATION
----------------------
In 8.1.7.0.0, parameter USE_SHARED_SOCKET no longer works due to [BUG:1566794].
However, the bug is fixed in Oracle Server patchset 8.1.7.2.0 onwards.
Refer [NOTE:124140.1] for details.
RELATED DOCUMENTS
-----------------
[NOTE:124140.1] How to configure USE_SHARED_SOCKET on Windows NT/2000
[NOTE:66382.1] Firewalls, Windows NT and Redirections
[NOTE:2077721.6] Installation and Configurationfor Net8 Connection Manager
Net8 Administrator's Guide
This bulletin is intended for database and network administrators who need
to enable SQL*Net/Net8 database connections via a firewall to Windows NT or
Windows 2000 based databases.
This can be handled by applying a firewall that has a SQL*Net proxy built in.
The way this works is that the SQL*Net proxy starts another listening process
(usually on port 1610). This causes the firewall to act like a Connection
Mananger or Multi Protocol Interchange.
The second way to resolve this issue is to upgrade the server to 8.0.x or 8.1.x
and to set the USE_SHARED_SOCKET parameter in the registry in order to
activate port sharing under WINNT. The parameter is available in Windows NT 4.0
(SP3 or higher) and Windows 2000 when Winsock 2 support is installed. With this
method, it is also possible to use firewalls which only supports port filtering
and no SQL*Net proxy. At least for dedicated connections. Multi Threaded Server
(MTS) still needs to redirect the connection to a dynamic port and therefore
requires a SQL*Net proxy.
USE_SHARED_SOCKET = TRUE
The parameter can also be set within the WINNT registry under
\\HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE (Relases 8.0) or
\\HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME<#> (Release 8i )
EXAMPLE of configuration
-------------------------
Tnsnames.ora
Example_shared_socket =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =<nodename>)(PORT = 1500))
)
(CONNECT_DATA =
(SERVICE_NAME =<sid>)
)
)
Listener.ora
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <nodename>)(PORT = 1500))
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = <global db name if used>)
(SID_NAME = <sid>)
)
)
Troubleshooting notes
----------------------
A successful configuration can be seen using the 'netstat -a' command from a
Command Prompt
OR
TRACE_LEVEL_CLIENT= 16
TRACE_DIRECTORY_CLIENT = <directory>
TRACE_FILE_DIRECTORY= <filename>
By searching for the string 'port' in the trace file, the only port seen is
the one specified.
The listener can be stopped without interupting the connected sessions, but it
cannot be restarted without forcibly disconnecting connected sessions first.
Special Note:
=============
If using TCPS protocol or SSL, port re-direction will occur. The only
solution is to use firewall vendor that supports Sqlnet/Net8 connectivity or
configure Multi-Threaded Server (MTS).
RELATED DOCUMENTS
-----------------
Note:66382.1 FIREWALLS, WINDOWS NT AND REDIRECTIONS
Note:1012783.102 THE COMPLETE TNS-12203 FOR TCP BULLETIN
PURPOSE
RELATED DOCUMENTS
[NOTE:45226.1] SQL*Net and Firewalls
On Windows NT, when a connect request comes in to the listener, the listener
spawns an Oracle thread. This thread is a listening thread and is started
on a wild-card address, meaning that the thread is listening for connections
on the current IP address and an unused port number given to the thread by
the networking software. The Oracle thread will contact the listener using
IPC and inform the listener of its listening address, connection load, and
some other status information. The listener sends back to the client a
REDIRECT address. This tells the client to reconnect to the newly spawned
Oracle thread. Since this Oracle thread is on a random port (a range of ports
cannot be defined), the firewall will not let the connection through.
The resulting error is usually a TNS-12203.
(i) The first way is to use a firewall that has a SQL*Net proxy built into
it. The way this works is that the SQL*Net proxy starts another listening
process (usually on port 1610). This causes the firewall to act as a
Multi-Protocol Interchange. So, by using the "tnsnav.ora" file on the
client, you connect to port 1610 (the firewall). The firewall passes the
connection to the server. The server gives a redirect to the client. The
client reconnects to the firewall proxy on port 1610, and the firewall
passes the connection to the Oracle thread on the wild-card listening
address. Here's what the connection flow would look like:
firewall
||
+------+ <--------2--------||-------2------ +---------+
|client| || |listener |(port=1521)
+------+ --------1------> proxy ----1------> +---------+
A \ /||\
| \---------3-------/ || \-----3------> +---------+
| || | oracle |(port=xxxx)
+--------------4---------||-------4------- +---------+
(ii) The second way to resolve this issue is to upgrade the server to 8.0.x
and use the USE_SHARED_SOCKET parameter in the registry. With this
method, it doesn't matter what kind of firewall you have. The syntax
for this parameter is:
USE_SHARED_SOCKET = TRUE
Restart Oracle and the listener for the parameter to take effect.
+---<O>--------<O>----<O>---<O>--+
| |
| This square represents <O>
| a listening socket for |
| port 1521. |
<O> |
| <O> = oracle thread <O>
| <L> = listener |
| |
+-<O>-------<L>--<O>------<O>----+
Finally, a very common question concerning the listener and port numbers is
why different port numbers show up in the "listener.log" file. What you are
seeing is the client's source port and client's source IP address. Here is
how this relates to your firewall:
source destination
+-----------+---------------+
IP |138.2.12.8 |185.45.67.53 |
+-----------+---------------+
port | xx | 23 |
+-----------+---------------+
Notice I have labeled the source port as 'xx'. What happens is that the
networking software on the client chooses at random, or in sequential order,
a valid port (between 1024 and 65535) so the client can send and receive data.
This is what you are seeing in the "listener.log" file.
Question: Will this be a problem with the firewall?
Answer: No. The firewall will restrict incoming connections, but will
freely let any connection on any port out (which is okay).
Firewall
<-------------||---------\
<-------------||---------\\
[CLIENT]----------------->|| \---[SERVER]
<-------------||---------//
<-------------||---------/
Search Words:
=============
ORA-12203
PURPOSE
-------
External.
DESCRIPTION
-----------
PROBLEM
-------
Clients that reside outside of NAT router can only access systems inside the
NAT router by using their external IP addresses. In this situation, the server
where the Listener resides is assigned an internal IP address. The client
successfully connects to the listener through the NAT by referencing the
external IP address of the server. The Listener then spawns a dedicated server
process and sends a redirect address back to the client to connect to. The
redirect address includes the internal IP address of the data server.
When the client attempts to connect back to the redirect address, it fails
because the client can only use the external address of the server. This is an
issue affecting both Unix and Windows databases.
NAT
external IP | internal IP
addresses | addresses
------ (192.168.255.x ) | (10.1.54.x) --------
|client|------------------>>>|>>>------------------|database|
------ | --------
|
NAT
SOLUTION
--------
NAT
external IP | internal IP
------ addresses | addresses ---------- --------
|client|----------------->>>|>>>------------|connection|------|database|
------ | | manager | --------
| ----------
NAT
The key to making this work is the placement of the IP addresses. The external
and internal addresses must be specified in the proper locations.
SAMPLE CONFIGURATION
--------------------
Client:
External IP address: 192.168.255.3.
Firewall/NAT Router:
External IP address: 200.1.255.1.
Connection Manager:
Internal IP address: 10.1.54.134.
NAT IP address: 200.1.255.5.
Data Server:
Internal IP address: 10.1.54.127.
NAT IP address: 200.1.255.10.
#TNSNAMES.ORA:
ORCL.WORLD =
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=200.1.255.5)(PORT=1610)) # external IP address
(ADDRESS=(PROTOCOL=tcp)(HOST=10.1.54.127)(PORT=1521)) # internal IP address
)
(CONNECT_DATA=
(SID = ORCL)
)
(SOURCE_ROUTE = yes)
)
#CMAN.ORA
CMAN =
(ADDRESS_LIST =
(ADDRESS =(PROTOCOL=tcp)(HOST=10.1.54.134)(PORT=1610)) # internal IP address
)
#LISTENER.ORA:
LISTENER =
(ADDRESS_LIST =
(ADDRESS= (PROTOCOL=tcp)(HOST=10.1.54.127)(PORT=1521)) # internal IP address
)
SID_LIST_LISTENER =
(SID_LIST=
(SID_DESC =
(ORACLE_HOME= /u01/app/oracle/product/8.1.7)
(SID_NAME = ORCL)
)
)
NOTES
-----
Beware of using access control with CMAN and NAT addresses. The CMAN_RULES
section of the CMAN.ORA uses source and destination IP addresses to limit
access to services. Since NAT is being used, the source and destination
addresses may not be correctly interpretable by CMAN, thus causing ORA-12204
error when connecting from the client.
The configuration described in this note will only work if the NAT server has
port forwarding enabled. A number of the more popular NAT servers have this
feature disabled by default.
RELATED ARTICLES
----------------