9 if [ $# -eq 1 -a "x$1" = "xremove" ]
11 $IPTABLES -D INPUT
-m set --match-set "${set_name}" src
-j ACCEPT
|| echo "no rule '${set_name}' to remove"
12 $IP6TABLES -D INPUT
-m set --match-set "${set_name}6" src
-j ACCEPT
|| echo "no rule '${set_name}6' to remove"
13 $IPSET destroy
"${set_name}" || echo "no set '${set_name}' to remove"
14 $IPSET destroy
"${set_name}6" || echo "no set '${set_name}6' to remove"
18 create_set
"${set_name}" hash:net
19 create_set
"${set_name}" hash:net family inet6
22 if ! $IPTABLES -C INPUT
-m set --match-set "${set_name}" src
-j ACCEPT
>/dev
/null
2>&1
24 echo "initializing rule '${set_name}'"
25 $IPTABLES -I INPUT
-m set --match-set "${set_name}" src
-j ACCEPT
29 if ! $IP6TABLES -C INPUT
-m set --match-set "${set_name}6" src
-j ACCEPT
>/dev
/null
2>&1
31 echo "initializing rule '${set_name}6'"
32 $IP6TABLES -I INPUT
-m set --match-set "${set_name}6" src
-j ACCEPT
35 if [ -e "${set_name}.cidr" ]
37 echo "updating set '${set_name}'"
38 $IPSET create
"${set_name}-tmp" hash:net
39 for s
in $(decommentcat "${set_name}.cidr" | grep '\.')
41 $IPSET add
"${set_name}-tmp" "${s}"
43 $IPSET swap
"${set_name}-tmp" "${set_name}"
44 $IPSET destroy
"${set_name}-tmp"
45 $IPSET list
-t "${set_name}"
47 echo "updating set '${set_name}6'"
48 $IPSET create
"${set_name}6-tmp" hash:net family inet6
49 for s
in $(decommentcat "${set_name}.cidr" | grep '\:')
51 $IPSET add
"${set_name}6-tmp" "${s}"
53 $IPSET swap
"${set_name}6-tmp" "${set_name}6"
54 $IPSET destroy
"${set_name}6-tmp"
55 $IPSET list
-t "${set_name}6"