Bug#673491: tayga: [patch] allow adding addresses to the TUN interface

May 18th, 2012 - 08:40 pm ET by Kenyon Ralph | Report spam



Package: tayga
Version: 0.9.2-4
Severity: wishlist
Tags: patch

Attached is a patch that allows you to add IP addresses to the TUN
interface using /etc/default/tayga. Having addresses on this interface
is desirable according to Q3.3 and Q3.4 of the TAYGA FAQ:
http://www.litech.org/tayga/faq.html

Debian Release: 6.0.5
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'proposed-updates'), (500, 'stable'), (50, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-0.bpo.2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Kenyon Ralph


# HG changeset patch
# User kenyon@kenyonralph.com
# Date 1337387488 25200
# Node ID 246f594f4a04790a5cea1230e042430517344261
# Parent 7797474c516516b111dc611bb420b93acf6e5acd
default, init: allow adding addresses to the TUN interface

diff -r 7797474c5165 -r 246f594f4a04 debian/default
a/debian/default Tue Apr 17 22:31:36 2012 +0100
+++ b/debian/default Fri May 18 17:31:28 2012 -0700
@@ -13,3 +13,9 @@

# Additional options that are passed to the Daemon.
DAEMON_OPTS=""
+
+# IPv4 address to assign to the tun64 device
+IPV4_TUN_ADDR=""
+
+# IPv6 address to assign to the tun64 device
+IPV6_TUN_ADDR=""
diff -r 7797474c5165 -r 246f594f4a04 debian/init
a/debian/init Tue Apr 17 22:31:36 2012 +0100
+++ b/debian/init Fri May 18 17:31:28 2012 -0700
@@ -109,6 +109,8 @@
ip link set $TUN_DEVICE up
ip route add $DYNAMIC_POOL dev nat64
ip route add $IPV6_PREFIX dev nat64
+ [ -n "$IPV4_TUN_ADDR" ] && ip addr add $IPV4_TUN_ADDR dev nat64
+ [ -n "$IPV6_TUN_ADDR" ] && ip addr add $IPV6_TUN_ADDR dev nat64
fi
[ "x$CONFIGURE_NAT44" = "xyes" ] && iptables -t nat -A POSTROUTING -s $DYNAMIC_POOL -j MASQUERADE || true








To UNSUBSCRIBE, email to debian-bugs-dist-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
email Follow the discussionReplies 5 repliesReplies Make a reply

Similar topics

Replies

#1 Kenyon Ralph
May 19th, 2012 - 02:00 am ET | Report spam

On 2012-05-18T17:35:17-0700, Kenyon Ralph wrote:
+# IPv4 address to assign to the tun64 device
+IPV4_TUN_ADDR=""
+
+# IPv6 address to assign to the tun64 device
+IPV6_TUN_ADDR=""



Oops, I meant nat64 device, not tun64.

Kenyon Ralph






To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
#2 SamLT
June 11th, 2012 - 09:10 am ET | Report spam


Hello,

Same idea, but I leave here the default file untouched, and find the
IPv4/IPv6 addresses from the tayga config(ipv4-addr/ipv6-addr), as for
the other parameters(prefix, dynamic-pool...).

patch attached and pasted below for completness.


Thanks for your work.

sam


debian/init 2012-06-11 14:43:36.902006173 +0200
+++ debian/init.new 2012-06-11 14:42:31.787831726 +0200
@@ -67,6 +67,8 @@
TUN_DEVICE=$(sed -rn "/^[ \t]*tun-device/s/^[ \t]*tun-device[ \t]+//p" /etc/tayga.conf)
IPV6_PREFIX=$(sed -rn "/^[ \t]*prefix/s/^[ \t]*prefix[ \t]+//p" /etc/tayga.conf)
DYNAMIC_POOL=$(sed -rn "/^[ \t]*dynamic-pool/s/^[ \t]*dynamic-pool[ \t]+//p" /etc/tayga.conf)
+IPV4_TUN_ADDR=$(sed -rn "/^[ \t]*ipv4-addr/s/^[ \t]*ipv4-addr[ \t]+//p" /etc/tayga.conf)
+IPV6_TUN_ADDR=$(sed -rn "/^[ \t]*ipv6-addr/s/^[ \t]*ipv6-addr[ \t]+//p" /etc/tayga.conf)
CONFIGURE_IFACE="no"
CONFIGURE_NAT44="no"

@@ -109,6 +111,8 @@
ip link set $TUN_DEVICE up
ip route add $DYNAMIC_POOL dev nat64
ip route add $IPV6_PREFIX dev nat64
+ [ -z "$IPV4_TUN_ADDR" ] || ip addr add $IPV4_TUN_ADDR dev $TUN_DEVICE
+ [ -z "$IPV6_TUN_ADDR" ] || ip addr add $IPV6_TUN_ADDR dev $TUN_DEVICE
fi
[ "x$CONFIGURE_NAT44" = "xyes" ] && iptables -t nat -A POSTROUTING -s $DYNAMIC_POOL -j MASQUERADE || true



debian/init 2012-06-11 14:43:36.902006173 +0200
+++ debian/init.new 2012-06-11 14:42:31.787831726 +0200
@@ -67,6 +67,8 @@
TUN_DEVICE=$(sed -rn "/^[ \t]*tun-device/s/^[ \t]*tun-device[ \t]+//p" /etc/tayga.conf)
IPV6_PREFIX=$(sed -rn "/^[ \t]*prefix/s/^[ \t]*prefix[ \t]+//p" /etc/tayga.conf)
DYNAMIC_POOL=$(sed -rn "/^[ \t]*dynamic-pool/s/^[ \t]*dynamic-pool[ \t]+//p" /etc/tayga.conf)
+IPV4_TUN_ADDR=$(sed -rn "/^[ \t]*ipv4-addr/s/^[ \t]*ipv4-addr[ \t]+//p" /etc/tayga.conf)
+IPV6_TUN_ADDR=$(sed -rn "/^[ \t]*ipv6-addr/s/^[ \t]*ipv6-addr[ \t]+//p" /etc/tayga.conf)
CONFIGURE_IFACE="no"
CONFIGURE_NAT44="no"

@@ -109,6 +111,8 @@
ip link set $TUN_DEVICE up
ip route add $DYNAMIC_POOL dev nat64
ip route add $IPV6_PREFIX dev nat64
+ [ -z "$IPV4_TUN_ADDR" ] || ip addr add $IPV4_TUN_ADDR dev $TUN_DEVICE
+ [ -z "$IPV6_TUN_ADDR" ] || ip addr add $IPV6_TUN_ADDR dev $TUN_DEVICE
fi
[ "x$CONFIGURE_NAT44" = "xyes" ] && iptables -t nat -A POSTROUTING -s $DYNAMIC_POOL -j MASQUERADE || true





To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
#3 SamLT
June 11th, 2012 - 10:30 am ET | Report spam
On Mon, Jun 11, 2012 at 03:00:24PM +0200, SamLT wrote:
@@ -109,6 +111,8 @@
ip link set $TUN_DEVICE up
ip route add $DYNAMIC_POOL dev nat64
ip route add $IPV6_PREFIX dev nat64



Oh, and ny the way, those two last lines should use $TUN_DEVICE instead
of the default 'nat64' name

ip route add $DYNAMIC_POOL dev $TUN_DEVICE
ip route add $IPV6_PREFIX dev $TUN_DEVICE






To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
#4 Kenyon Ralph
June 11th, 2012 - 01:30 pm ET | Report spam

On 2012-06-11T15:00:24+0200, SamLT wrote:
Same idea, but I leave here the default file untouched, and find the
IPv4/IPv6 addresses from the tayga config(ipv4-addr/ipv6-addr), as for
the other parameters(prefix, dynamic-pool...).



I believe your patch is not correct because the nat64 TUN device
should have addresses from different networks than what TAYGA is
using. The ipv4-addr and ipv6-addr (or the address TAYGA generates
using ipv4-addr and the IPv6 NAT64 prefix) in /etc/tayga.conf are used
internally by TAYGA and will not be visible in 'ip address show'
output. So you need to create new configuration variables outside of
tayga.conf, which is why I added variables to /etc/default/tayga.

patch attached and pasted below for completness.


Thanks for your work.

sam


debian/init 2012-06-11 14:43:36.902006173 +0200
+++ debian/init.new 2012-06-11 14:42:31.787831726 +0200
@@ -67,6 +67,8 @@
TUN_DEVICE=$(sed -rn "/^[ \t]*tun-device/s/^[ \t]*tun-device[ \t]+//p" /etc/tayga.conf)
IPV6_PREFIX=$(sed -rn "/^[ \t]*prefix/s/^[ \t]*prefix[ \t]+//p" /etc/tayga.conf)
DYNAMIC_POOL=$(sed -rn "/^[ \t]*dynamic-pool/s/^[ \t]*dynamic-pool[ \t]+//p" /etc/tayga.conf)
+IPV4_TUN_ADDR=$(sed -rn "/^[ \t]*ipv4-addr/s/^[ \t]*ipv4-addr[ \t]+//p" /etc/tayga.conf)
+IPV6_TUN_ADDR=$(sed -rn "/^[ \t]*ipv6-addr/s/^[ \t]*ipv6-addr[ \t]+//p" /etc/tayga.conf)
CONFIGURE_IFACE="no"
CONFIGURE_NAT44="no"

@@ -109,6 +111,8 @@
ip link set $TUN_DEVICE up
ip route add $DYNAMIC_POOL dev nat64
ip route add $IPV6_PREFIX dev nat64
+ [ -z "$IPV4_TUN_ADDR" ] || ip addr add $IPV4_TUN_ADDR dev $TUN_DEVICE
+ [ -z "$IPV6_TUN_ADDR" ] || ip addr add $IPV6_TUN_ADDR dev $TUN_DEVICE
fi
[ "x$CONFIGURE_NAT44" = "xyes" ] && iptables -t nat -A POSTROUTING -s $DYNAMIC_POOL -j MASQUERADE || true


debian/init 2012-06-11 14:43:36.902006173 +0200
+++ debian/init.new 2012-06-11 14:42:31.787831726 +0200
@@ -67,6 +67,8 @@
TUN_DEVICE=$(sed -rn "/^[ \t]*tun-device/s/^[ \t]*tun-device[ \t]+//p" /etc/tayga.conf)
IPV6_PREFIX=$(sed -rn "/^[ \t]*prefix/s/^[ \t]*prefix[ \t]+//p" /etc/tayga.conf)
DYNAMIC_POOL=$(sed -rn "/^[ \t]*dynamic-pool/s/^[ \t]*dynamic-pool[ \t]+//p" /etc/tayga.conf)
+IPV4_TUN_ADDR=$(sed -rn "/^[ \t]*ipv4-addr/s/^[ \t]*ipv4-addr[ \t]+//p" /etc/tayga.conf)
+IPV6_TUN_ADDR=$(sed -rn "/^[ \t]*ipv6-addr/s/^[ \t]*ipv6-addr[ \t]+//p" /etc/tayga.conf)
CONFIGURE_IFACE="no"
CONFIGURE_NAT44="no"

@@ -109,6 +111,8 @@
ip link set $TUN_DEVICE up
ip route add $DYNAMIC_POOL dev nat64
ip route add $IPV6_PREFIX dev nat64
+ [ -z "$IPV4_TUN_ADDR" ] || ip addr add $IPV4_TUN_ADDR dev $TUN_DEVICE
+ [ -z "$IPV6_TUN_ADDR" ] || ip addr add $IPV6_TUN_ADDR dev $TUN_DEVICE
fi
[ "x$CONFIGURE_NAT44" = "xyes" ] && iptables -t nat -A POSTROUTING -s $DYNAMIC_POOL -j MASQUERADE || true





Kenyon Ralph






To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Replies Reply to this message
#5 SamLT
June 11th, 2012 - 04:10 pm ET | Report spam
On Mon, Jun 11, 2012 at 10:26:06AM -0700, Kenyon Ralph wrote:
On 2012-06-11T15:00:24+0200, SamLT wrote:
> Same idea, but I leave here the default file untouched, and find the
> IPv4/IPv6 addresses from the tayga config(ipv4-addr/ipv6-addr), as for
> the other parameters(prefix, dynamic-pool...).

I believe your patch is not correct because the nat64 TUN device
should have addresses from different networks than what TAYGA is
using. The ipv4-addr and ipv6-addr (or the address TAYGA generates
using ipv4-addr and the IPv6 NAT64 prefix) in /etc/tayga.conf are used
internally by TAYGA and will not be visible in 'ip address show'
output. So you need to create new configuration variables outside of
tayga.conf, which is why I added variables to /etc/default/tayga.




You're right, now that I read the doc again, I don't now what I was
thinking!

So for the maintainer, forget my patch, but probably keep the comment
about the $TUN_DEVICE variable in mind.

Thanks for your comment Kenyon Ralph.

sam



To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
email Follow the discussion Replies Reply to this message
Help Create a new topicReplies Make a reply
Search Make your own search