2 Replies Latest reply: Jun 1, 2011 3:29 AM by theoa RSS

    how to get database server IP address?

    650063
      I have Php backend website, where i have a text area to run sql queries against underlying Oracle 10g/solaris database.
      I have ca 10 such Backend web sites, and 10 underlying Oracle databases for each website. Each Backend website lives different computer than Backend Php webserver.
      I have problems to understand what is the database IP of the Backend website.
      Can i query it?

      My example wrong queries:
      I know that underlying database in this example is with IP "192.168.2.165", but i canät manage to query that out, see:
      This is not the database IP:
      
      select UTL_INADDR.GET_HOST_ADDRESS from dual--127.0.0.1 
      
      This is some mysterical computer name that i cant ping:
      
      select UTL_INADDR.GET_HOST_NAME from dual;--tar_071_z
      
      This is wrong IP:
      select UTL_INADDR.GET_HOST_ADDRESS('tar_071_z') from dual;--127.0.0.1
      
      Wrong:
      select UTL_INADDR.GET_HOST_ADDRESS( UTL_INADDR.GET_HOST_NAME ) from dual;--127.0.0.1
      
      I don't know what IP is that:
      
      select sys_context('USERENV','IP_ADDRESS') from dual;--192.168.2.160 
      
      My php-website i run queries in this example:
      
      C:\Users\charlesr>ping myphpbackend.com
      
      Pinging admin.live.casino.playtech.com [192.168.2.160] with 32 bytes of data:
      Reply from 192.168.2.160: bytes=32 time=17ms TTL=252
      Reply from 192.168.2.160: bytes=32 time=9ms TTL=252
      Reply from 192.168.2.160: bytes=32 time=6ms TTL=252
      Reply from 192.168.2.160: bytes=32 time=7ms TTL=252
      
      Ping statistics for 192.168.2.160:
          Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
      Approximate round trip times in milli-seconds:
          Minimum = 6ms, Maximum = 17ms, Average = 9ms
      
      C:\Users\charlesr>
      
      ---
      
      C:\Users\charlesr>ping tar_071_z
      Ping request could not find host tar_071_z. Please check the name and try again.
      
      ---
      
      If i type Into my Windows 7 File Explorer address "\\tar_071_z" then it says it doesn't find the computer.
      
      ---
      
      
      C:\Users\charlesr>ipconfig
      
      Windows IP Configuration
      
      
      Ethernet adapter Local Area Connection:
      
         Connection-specific DNS Suffix  . : videobet.corp
         Link-local IPv6 Address . . . . . : fe80::702d:f154:fb5e:5c20%11
         IPv4 Address. . . . . . . . . . . : 192.168.15.105
         Subnet Mask . . . . . . . . . . . : 255.255.255.0
         Default Gateway . . . . . . . . . : 192.168.15.1
      
      Tunnel adapter isatap.videobet.corp:
      
         Media State . . . . . . . . . . . : Media disconnected
         Connection-specific DNS Suffix  . : videobet.corp
      
      Tunnel adapter Teredo Tunneling Pseudo-Interface:
      
         Media State . . . . . . . . . . . : Media disconnected
         Connection-specific DNS Suffix  . :
      
      C:\Users\charlesr>
      Edited by: CharlesRoos on 1.06.2011 10:59
        • 1. Re: how to get database server IP address?
          800252
          try this:

          select sys_context('USERENV','IP_ADDRESS') from dual;


          also, 127.0.0.1 is a loopback address (localhost), and not ping-able...

          on a side note: working with IP address's is not advisable in large complex systems, should always try to use the hostname that way if IP address is changed does not impact the application conectivity....

          HTH....
          • 2. Re: how to get database server IP address?
            theoa
            user8950100 wrote:
            try this:

            select sys_context('USERENV','IP_ADDRESS') from dual;
            That would give you the client ip address, not the server.
            on a side note: working with IP address's is not advisable in large complex systems, should always try to use the hostname that way if IP address is changed does not impact the application conectivity....
            Why would you need the IP address of the database server anyway?
            Each database should have a unique name, use that instead.
            sql> select ora_database_name from dual;
            
            ORA_DATABASE_NAME
            -------------------
            xxxx.xx.xxx.xxx.xx
            (database name mangled to protect the innocent)