Piyush
Piyush

Reputation: 5315

SELECT sys_context('userenv','ip_address') FROM dual returns IPV4 but sometimes it returns IPV6

I am using Oracle 19.10.0.0 database. for some application server below query returns IPV4 but for some other application server it is returning IPV6.

SELECT sys_context('userenv','ip_address') FROM dual.

Could we make sure that this return always IPV4 only?

Thanks in advance.

Upvotes: 0

Views: 1460

Answers (1)

kfinity
kfinity

Reputation: 9091

IP_ADDRESS shows the client IP address - if they connected using IPv6, it'll show that address. In that case the server does not know that client's IPv4 address, so there's no way to show it.

If you don't want clients to be able to use IPv6, you would need to disable IPv6 connections. The easiest way would probably be to disable IPv6 in the Oracle Listener, but you could also reconfigure the server OS's network connection to not use IPv6.

Example listener.ora entry:

listener_name=
 (DESCRIPTION=
  (ADDRESS=(PROTOCOL=tcp)(HOST=appservername)(PORT=1521)(IP=V4_ONLY))

Upvotes: 3

Related Questions