• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

OpenVPN Server Notification on Connect

Scheduled Pinned Locked Moved OpenVPN
3 Posts 3 Posters 2.8k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J
    joelones
    last edited by Jul 23, 2017, 9:07 PM Jul 23, 2017, 9:01 PM

    Hi,
    I'm trying to configure an email on connect to the pfsense openvpn server. I searched and came across a post suggesting to modify the file: /usr/local/sbin/openvpn.attributes.sh in the "client-connect" sections. I put some echos in there for output in a file, but I see nothing once a connection is established. Seems like the script is not running, but could this be only for the OpenVPN client connections and not server connections?

    Edit: I may have my answer here I guess: https://forum.pfsense.org/index.php?topic=95947.0

    1 Reply Last reply Reply Quote 2
    • X
      xl
      last edited by Jul 25, 2017, 6:47 AM Jul 25, 2017, 6:35 AM

      You can use up/down scripts:
      Add to custom server options:

      script-security 3 system;
      client-connect /usr/local/sbin/up.sh;
      client-disconnect /usr/local/sbin/down.sh;
      

      up.sh:

      #!/bin/sh
      
      /full/path/to/your/console/email/app
      

      down.sh:

      #!/bin/sh
      
      /full/path/to/your/console/email/app
      

      mailx example:

      echo "Client $common_name connected to $HOSTNAME" | mailx -r "your@mail.com" -s "Client $common_name connected to $HOSTNAME from $trusted_ip" -S smtp="your.smtp.com:25" -S smtp-auth=login -S smtp-auth-user="usr@smtp.com" -S smtp-auth-password="password" touser@mail.com > /dev/null
      

      OpenVPN vars that you can use:
      $common_name
      $HOSTNAME
      $ifconfig_local
      $ifconfig_pool_remote_ip
      $untrusted_ip
      $trusted_ip
      $dev

      1 Reply Last reply Reply Quote 1
      • J
        JZng
        last edited by JZng May 30, 2019, 8:05 PM May 30, 2019, 8:02 PM

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
          [[user:consent.lead]]
          [[user:consent.not_received]]