Mailing List Archive

[PATCH] delete tun address on disconnect
This enables persist tun device to be reused in future
connections.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
---
vpnc-script | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/vpnc-script b/vpnc-script
index f206dfd..1642727 100755
--- a/vpnc-script
+++ b/vpnc-script
@@ -661,6 +661,11 @@ do_disconnect() {
if [ -n "$INTERNAL_IP4_DNS" ]; then
$RESTORERESOLVCONF
fi
+
+ if [ -n "$IPROUTE" ]; then
+ $IPROUTE addr del "$INTERNAL_IP4_ADDRESS/255.255.255.255" peer "$INTERNAL_IP4_ADDRESS" dev "$TUNDEV"
+ fi
+
destroy_tun_device
}

--
1.7.8.6

_______________________________________________
vpnc-devel mailing list
vpnc-devel@unix-ag.uni-kl.de
https://lists.unix-ag.uni-kl.de/mailman/listinfo/vpnc-devel
http://www.unix-ag.uni-kl.de/~massar/vpnc/
Re: [PATCH] delete tun address on disconnect [ In reply to ]
On Tue, 2012-07-03 at 22:12 +0300, Alon Bar-Lev wrote:
> This enables persist tun device to be reused in future
> connections.

> + if [ -n "$IPROUTE" ]; then
> + $IPROUTE addr del "$INTERNAL_IP4_ADDRESS/255.255.255.255" peer "$INTERNAL_IP4_ADDRESS" dev "$TUNDEV"
> + fi

That just takes down the Legacy IP address. Please make sure you take
down the IPv6 address too.

--
dwmw2
[PATCH] delete tun address on disconnect [ In reply to ]
This enables persist tun device to be reused in future
connections.

ipv6 is not tested.

Maybe it would be cleaner to define functions for address
manipulation, not sure.

To be simple, this patch only handles iproute2.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
---
vpnc-script | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/vpnc-script b/vpnc-script
index f206dfd..e3cd4db 100755
--- a/vpnc-script
+++ b/vpnc-script
@@ -661,6 +661,20 @@ do_disconnect() {
if [ -n "$INTERNAL_IP4_DNS" ]; then
$RESTORERESOLVCONF
fi
+
+ if [ -n "$IPROUTE" ]; then
+ if [ -n "$INTERNAL_IP4_ADDRESS" ]; then
+ $IPROUTE addr del "$INTERNAL_IP4_ADDRESS/255.255.255.255" peer "$INTERNAL_IP4_ADDRESS" dev "$TUNDEV"
+ fi
+ # If the netmask is provided, it contains the address _and_ netmask
+ if [ -n "$INTERNAL_IP6_ADDRESS" ] && [ -z "$INTERNAL_IP6_NETMASK" ]; then
+ INTERNAL_IP6_NETMASK="$INTERNAL_IP6_ADDRESS/128"
+ fi
+ if [ -n "$INTERNAL_IP6_NETMASK" ]; then
+ $IPROUTE -6 addr del $INTERNAL_IP6_NETMASK dev $TUNDEV
+ fi
+ fi
+
destroy_tun_device
}

--
1.7.8.6

_______________________________________________
vpnc-devel mailing list
vpnc-devel@unix-ag.uni-kl.de
https://lists.unix-ag.uni-kl.de/mailman/listinfo/vpnc-devel
http://www.unix-ag.uni-kl.de/~massar/vpnc/