--- a/gogoc-tsp/template/linux.sh
+++ b/gogoc-tsp/template/linux.sh
@@ -67,6 +67,31 @@
    $* # Execute command
 }
 
+SubInterfaces()
+{
+   if [ -f /etc/gogoc/interfaces.conf ] ; then
+	cat /etc/gogoc/interfaces.conf | sed -e 's/#.*$//' -e 's/[[:space:]]*$//' -e 's/^[[:space:]]//' -e '/^$/d' | nl -n ln
+   fi
+}
+
+SubNet()
+{
+   net="$1"
+   mask=64
+   test -z "$3" || mask="$3"
+   sub="$2"
+
+   subnet="`sipcalc -S "$mask" "$net" | grep '^Network' | sed -e 's/^Network[[:space:]]*-[[:space:]]//' -e 's/[[:space:]]*-[[:space:]]*$//'`"
+   if [ "$sub" -ne 0 ] ; then
+      pref="`echo "$subnet" | tail -n +2 | head -n "$sub" | tail -n 1`"
+   else
+      pref="`echo "$subnet" | head -n 1`"
+   fi
+   test -z "$pref" && return 1
+   echo "$pref" | sed 's/:0000:0000:0000:0000$//'
+}
+
+
 # Program localization 
 
 Display 1 "--- Start of configuration script. ---"
@@ -135,6 +160,12 @@
 
     # Remove address from TSP HOME INTERFACE
     ExecNoCheck $ifconfig $TSP_HOME_INTERFACE inet6 del $TSP_PREFIX::1/64
+
+    subif="`SubInterfaces`"
+    echo "$subif" | while read sub int ; do
+       PREF="`SubNet "${TSP_PREFIX}::0/${TSP_PREFIXLEN}" "$sub"`"
+       ExecNoCheck $ifconfig "$int" inet6 del ${PREF}::1/64
+    done
   fi
 
   # Delete default IPv6 route(s).
@@ -242,6 +273,18 @@
    Display 1 "Adding prefix to $TSP_HOME_INTERFACE"
    Exec $ifconfig $TSP_HOME_INTERFACE add $TSP_PREFIX::1/64
 
+   subif="`SubInterfaces`"
+   echo "$subif" | while read sub int ; do
+      PREF=`echo $TSP_PREFIX | sed 's/00$//'`
+      OLDADDR=`$ifconfig "$int" | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
+      if [ ! -z $OLDADDR ]; then
+         Display 1 "Removing old IPv6 address $OLDADDR from $int"
+         Exec $ifconfig "$int" inet6 del $OLDADDR
+      fi
+      PREF="`SubNet "${TSP_PREFIX}::0/${TSP_PREFIXLEN}" "$sub"`"
+      Display 1 "Adding prefix ${PREF} to $int"
+      Exec $ifconfig "$int" inet6 add "${PREF}::1/64"
+   done
 
    # Stop radvd daemon if it was running. Twice.
    /etc/init.d/radvd stop
@@ -264,6 +307,22 @@
 };
 EOF
 
+   echo "$subif" | while read sub int ; do
+      PREF="`SubNet "${TSP_PREFIX}::0/${TSP_PREFIXLEN}" "$sub"`"
+      cat >> "$rtadvdconfigfile" <<EOF
+interface $int
+{
+  AdvSendAdvert on;
+  AdvLinkMTU 1280;
+  prefix ${PREF}::/64
+  {
+    AdvOnLink on;
+    AdvAutonomous on;
+  };
+};
+EOF
+   done
+
    # Start the radvd daemon.
    Display 1 "Starting radvd: $rtadvd -u radvd -C $rtadvdconfigfile"
    Exec $rtadvd -u radvd -p $rtadvd_pid -C $rtadvdconfigfile
