Capture the IP ADDRESSES of the users connecting to the Oracle database


Step 1 :  Create table for storing the IP addresses

Create table USER_IPS( IP_ADDRESS VARCHAR2(15),  USER_LOGGED VARCHAR2(50));

Step 2:  Create a logon trigger to capture the ip addresses

create or replace trigger USER_IPS
after logon on database
DECLARE

IP VARCHAR2(15);

BEGIN


   SELECT SYS_CONTEXT('USERENV', 'IP_ADDRESS', 15)   INTO IP FROM DUAL;

  INSERT INTO USER_IPS values(IP,USER) ;


EXCEPTION
    WHEN NO_DATA_FOUND THEN NULL;
     
end;
/


SQL>SELECT * FROM USER_IPS;

IP_ADDRESS      USER_LOGGED
--------------- --------------------------------------------------
10.18.7.11     PORTAL
10.35.9.12      PORTAL
10.35.9.23      PORTAL

Post a Comment

And that's all there is to it!

If anyone has any other questions or requests for future How To posts, you can either ask them in the comments or email me. Please don't feel shy at all!

I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

Previous Post Next Post