0 Replies Latest reply on Sep 4, 2010 5:43 PM by martin.dimov

    How to get the usernames and IPs of current logged VPN users

    martin.dimov

      Do anyone knows how to get the usernames and IPs of current logged VPN users?

       

      Because I do not know I wrote a script and I post it. Enjoy. Just give some feedback - do You find it usefull?

       

       

      to execute the script and see result:

      sw01:Admn {81} % cf ipsec policydump | awk -f test.awk
      1 - 192.168.5.19[any] user_name=test1
      4 - 192.168.5.18[any] user_name=mgradmin

       

       

      You could see in script - 192.168.5. This is my IPSec VPN client IP pool. Change it to match yours.

       

       

      the script:

      sw01:Admn {80} % cat test.awk
      BEGIN {
      netw=1;
      user=1;
      }
      /user_name=*/ { username[netw] = $1; netw++; }
      $1 ~ /192.168.5./ { network[user] = $1; user++; }

      END {
      for ( i=1; i<netw; i++ )
                    { if ( i >1 )
                      {
                        exist=0;
                        for ( n=1; n<i; n++ )
                        {
                              if (username[i] == username[n]) { n=i+1; exist=1 }
                        }
                        if (!exist) { print i" -", network[i], username[i] }
                      }
                    else { print i" -", network[i], username[i] }
                    }
      }

       

       

      Message was edited by: martin.dimov on 9/4/10 5:40:45 PM CDT

       

       

      Message was edited by: martin.dimov on 9/4/10 5:41:37 PM CDT

       

       

      Message was edited by: martin.dimov on 9/4/10 5:43:46 PM CDT