--to obtain the server-side IP -: $: theSYS@XXX> SelectUtl_inaddr.get_host_address fromdual; Get_host_address--------------------------------------------------10.19.2.XX--Resolving domain Names -: $: +SYS@XXX> SELECTUtl_inaddr.get_host_address ('www.anysql.net') fromdual; Utl_inaddr. Get_host_address ('WWW.ANYSQL.NET')--------------------------------------------------173.236.176.151--Reverse host name resolution based on IP address -: -: -SYS@XXX> SelectUtl_inaddr.get_host_name ('173.236.176.151') fromdual; Utl_inaddr. Get_host_name ('173.236.176.151')--------------------------------------------------Apache2-argon.footprint.dreamhost.com--Get client IP -: -: -SYS@XXX> SelectSys_context ('USERENV','IP_Address') ip_address fromdual;ip_address--------------------------------------------------10.19.2. XX--get the client host name -: -: -SYS@XXX> SelectSys_context ('Userenv','Host') fromdual; Sys_context ('USERENV','HOST')--------------------------------------------------Workgroup\wxx-THINK
UTL_INADDR Packet acquisition of IP information such as the implementation principle:
Refer to the article of the god of cover: http://www.eygle.com/archives/2006/10/how_to_getip_address.html
In Linux you can use the Strace command to track related commands, and in the trace information
Oracle sequentially accesses the following files to complete address positioning:
Open ("/etc/resolv.conf")open ("/etc/host.conf " A Open ("/etc/hosts"
First get the domain name resolution server, in accordance with the host.conf file to determine the resolution order, because the default Hosts file first, and continue to read the/etc/hosts file.
If the Hosts file has a parsing relationship, the information is returned, if it does not exist, the DNS server continues to be queried, the address is resolved, and if it cannot be resolved, an error occurs:
-: the: toSYS@XXX> SelectUtl_inaddr.get_host_address ('www.a.com') fromdual;SelectUtl_inaddr.get_host_address ('www.a.com') fromDual*Section1line error: ORA-29257: Unknown host Www.a.comORA-06512: In "SYS. Utl_inaddr ", line +ORA-06512: In "SYS. Utl_inaddr ", line +ORA-06512: On line1
In other words, UTL_INADDR's data acquisition is not dependent on database information, and Sys_context's information acquisition still comes from within the database.
Oracle acquires host server IP