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

Email notification if have connection OpenVPN

Scheduled Pinned Locked Moved OpenVPN
7 Posts 4 Posters 5.4k 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.
  • K
    karanik
    last edited by Sep 25, 2015, 10:04 AM Sep 25, 2015, 7:10 AM

    Hello,
    Is it  possible the pfSense OpenVPN server sent me email on every connection? Is pfSense able to send mail on every OpenVPN successful connection ?

    1 Reply Last reply Reply Quote 1
    • J
      jimp Rebel Alliance Developer Netgate
      last edited by Sep 28, 2015, 8:09 PM

      There is not currently a hook for e-mail notification there. It could be added without too much effort, at least a manual hacky way. A proper setup with a GUI option and so on would be a bit more complex.

      Have a look at the OpenVPN auth script in /var/etc/

      Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

      Need help fast? Netgate Global Support!

      Do not Chat/PM for help!

      1 Reply Last reply Reply Quote 0
      • K
        karanik
        last edited by Jun 27, 2016, 12:47 PM Oct 2, 2015, 6:57 AM

        Can i have example?

        [2.2.4-RELEASE][admin@pfsense]/root: ls /var/etc/
        apinger.conf                inetd.conf                  openvpn                     resolv.conf
        cert.pem                    l2tp-vpn                    openvpn-csc                 resolvconf.conf
        filterdns.conf              lighty-webConfigurator.conf radvd.conf                  squid.passwd
        hosts                       ntpd.conf                   relayd.conf                 syslog.conf
        
        
        1 Reply Last reply Reply Quote 0
        • J
          jimp Rebel Alliance Developer Netgate
          last edited by Oct 2, 2015, 2:12 PM

          I forgot things got shifted around, it's now at /etc/inc/openvpn.auth-user.php

          Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

          Need help fast? Netgate Global Support!

          Do not Chat/PM for help!

          1 Reply Last reply Reply Quote 0
          • S
            s_moffasecurex.ch
            last edited by Sep 29, 2016, 6:37 AM

            Hi,
            I don't know if you already find it, but it was my same request.
            To do that I just modify the connect and disconnect script on openvpn on pfsense 2.2.4

            /usr/local/sbin/openvpn.attributes.sh

            and add the line on connect and disconnect:

            /bin/echo "Connexion de ${common_name} date" | /usr/local/bin/php /usr/local/bin/mail.php -s"Connexion de ${common_name} date"

            Best regards,

            1 Reply Last reply Reply Quote 1
            • N
              n3by
              last edited by Jan 3, 2017, 9:06 PM

              Just to let you all know that if sending email fail ( because can't deliver email - mail server offline… ) the vpn connection will fail ( after established ) and clients will not be able to connect ever... I had to debug this problem today...

              1 Reply Last reply Reply Quote 0
              • K
                karanik
                last edited by Dec 13, 2017, 1:35 PM

                @s_moffa@securex.ch:

                Hi,
                I don't know if you already find it, but it was my same request.
                To do that I just modify the connect and disconnect script on openvpn on pfsense 2.2.4

                /usr/local/sbin/openvpn.attributes.sh

                and add the line on connect and disconnect:

                /bin/echo "Connexion de ${common_name} date" | /usr/local/bin/php /usr/local/bin/mail.php -s"Connexion de ${common_name} date"

                Best regards,

                Hello again.
                Now my version is 2.4.2-RELEASE (amd64) FreeBSD 11.1-RELEASE-p4
                and my /usr/local/sbin/openvpn.attributes.sh has

                
                #!/bin/sh
                #
                # openvpn.attributes.sh
                #
                # part of pfSense (https://www.pfsense.org)
                # Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
                # All rights reserved.
                #
                # Licensed under the Apache License, Version 2.0 (the "License");
                # you may not use this file except in compliance with the License.
                # You may obtain a copy of the License at
                #
                # http://www.apache.org/licenses/LICENSE-2.0
                #
                # Unless required by applicable law or agreed to in writing, software
                # distributed under the License is distributed on an "AS IS" BASIS,
                # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                # See the License for the specific language governing permissions and
                # limitations under the License.
                
                if [ "$script_type" = "client-connect" ]; then
                        if [ -f /tmp/$common_name ]; then
                                /bin/cat /tmp/$common_name > $1
                                /bin/rm /tmp/$common_name
                        fi
                elif [ "$script_type" = "client-disconnect" ]; then
                        command="/sbin/pfctl -a 'openvpn/$common_name' -F rules"
                        eval $command
                        /sbin/pfctl -k $ifconfig_pool_remote_ip
                        /sbin/pfctl -K $ifconfig_pool_remote_ip
                /usr/local/sbin/openvpn.attributes.sh
                fi
                
                exit 0
                
                

                how it should be done?

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                  This community forum collects and processes your personal information.
                  consent.not_received