source: npl/internetserver/openvpn_conf/root/etc/openvpn/update-ipset.sh @ 62266ed

Last change on this file since 62266ed was 76ea60c, checked in by Edwin Eefting <edwin@datux.nl>, 6 years ago

added ipset learning to openvpn, to allow firewalling based on openvpn certificate

  • Property mode set to 100755
File size: 596 bytes
Line 
1#!/bin/bash
2
3# Openvpn iptables rules based on certificate name.
4# (C)2018 SYN-3 edwin@datux.nl
5
6OPERATION=$1
7IP=$2
8CN=$3
9
10
11log()
12{
13 logger -t openvpn-update-ipset "$1"
14}
15
16# always make sure the ip doesnt exist in other sets (in case of bugs/openvpn restarts)
17log "Deleting $IP from all ipsets"
18for SET in `ipset list -n|grep ^openvpn_cert_`; do ipset del $SET $IP; done   
19
20
21if [ "$OPERATION" == "add" ] || [ "$OPERATION" == "update" ]; then
22    # add chain
23    log "Adding $IP to ipset openvpn_cert_$CN"
24    ipset create openvpn_cert_$CN hash:ip
25    ipset add openvpn_cert_$CN $IP
26fi
27
28
29exit 0
Note: See TracBrowser for help on using the repository browser.