I'm using a sh script (pasted below) to create an IPv6 tun interface using iproute with the tun mode.
#!/bin/sh # Create a new TUN interface for WPAN interaction. ip -6 tuntap add mode tun tun0 # Assign it a global IPv6 address. ip -6 addr add FF41::2 dev tun0 # Add route to default address of Serial TUN embedded interface. ip -6 route add FF41::1 dev tun0 # Add route to Unique Local /64 Prefix via tun0. ip -6 route add FF41:0000:0000:3EAD::/64 dev tun0 # The interface is ready. ip link set tun0 up # Enable IPv6 routing on host. sysctl -w net.ipv6.conf.all.forwarding=1
I would like to replace this script (that is called during startup) by a cleaner approach with
/etc/network/interfaces, however, I'm a bit stuck as how to create this file exactly.
The command for the route addition, I know I will be replacing them with appropriate pre-up stanza in
However, I'm not sure how to inform ifup that the interface to be created is a tun one.
Right now, my
/etc/network/interfaces looks like this:
# 802.15.4 Network auto tun0 iface tun0 inet6 static address FF41::2 netmask 64 pre-up ip -6 tuntap add mode tun tun0 pre-up ip -6 route add FF41::1 dev tun0 pre-up ip -6 route add FF41:0000:0000:3EAD::/64 dev tun0 post-up sysctl -w net.ipv6.conf.all.forwarding=1
On this device, I have a python script that uses pytun to link tun0 with a serial connection to an external device (that uses a 802.15.4 radio).
EDIT: It looks like I found a working solution using the above
interfaces file. However, I'm still open to inputs regarding a more elegant solution (if there is one!). Thanks!