Script client-connect

How to customize and extend your OpenVPN installation.
Post Reply
islthirion
OpenVpn Newbie
Posts: 3
Joined: Fri Jun 22, 2018 6:20 am

Script client-connect

Post by islthirion » Thu Aug 01, 2019 7:03 am

Hello

I have a connect.sh script in which i control the mac address of the client to check that it is in the list of allowed addresses

I would like the client to receive an AUTH_FAILED code to refuse the connection

Code: Select all

test_macaddress=`grep -r "$IV_HWADDR" /etc/openvpn/macaddress.txt`

if [ ${#test_macaddress} -eq 0 ]
then
        (
       echo $common_name $IV_HWADDR "MAC_NOK" >>/var/log/openvpn/macaddr.log
        exit 1
        )
else
        (
        echo $common_name $IV_HWADDR "MAC_OK" >>/var/log/openvpn/macaddr.log
        exit 0
        )
fi
if the mac address is not in the list the connection is accepted even with exit code 1

how to deny the client connection ?

Thanks for your help

Stéphane

islthirion
OpenVpn Newbie
Posts: 3
Joined: Fri Jun 22, 2018 6:20 am

Re: Script client-connect

Post by islthirion » Thu Aug 01, 2019 1:34 pm

I solved my problem by use the script in the OpenVPN server parameter : auth-user-pass-verify /etc/openvpn/scripts/verif_macaddress.sh via-file

Everything it's OK

Bye

Post Reply