-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlearn-address
38 lines (31 loc) · 1.24 KB
/
learn-address
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
##
# This script allows to share the same VPN subnet between TCP and UDP openvpn server
# Sudoers have to be setup to allow openvpn user to change routing table.
#
# This file created to work in chrooted environment using busybox
##
# Operation: "add", "update", or "delete" based on whether or not the address is being added to, modified, or deleted from OpenVPN's internal routing table.
MODE=$1
# Address: The address being learned or unlearned.
# This can be an IPv4 address such as "198.162.10.14",
# an IPv4 subnet such as "198.162.10.0/24",
# or an ethernet MAC address (when --dev tap is being used) such as "00:FF:01:02:03:04".
IP=$2
# Common Name: The common name on the certificate associated with the client linked to this address.
# Only present for "add" or "update" operations, not "delete".
# CN=$3
# Some environmental variables also available, e.g.: dev
case "${MODE}" in
add|update)
# exec -c sudo ip route add ${IP} dev ${dev} proto static scope link
echo "Learn: iproute del ${IP}"
iproute del ${IP}
echo "Learn: iproute add ${IP} dev ${dev} proto static scope link"
iproute add ${IP} dev ${dev} proto static scope link
;;
# delete)
# ;;
# update)
# ;;
esac