2

I have a linux gateway router running a 6to4 tunnel and using radvd to broadcast an IPv6 prefix on the local subnet. Radvd can be configured to automatically pick up the network prefix from the 6to4 interface, however I can't find a way to automatically assign a valid address to the local network interface (eth0).

For example, if my 6to4 inteface is autoconfigures to 2002:4185:9dd4::1/16, then eth0 needs an address of 2002:4185:9dd4:dead:<whatever>/64 (where 'dead' is the local subnet I configured in radvd.conf). With radvd running on the local machine, is there any way to force linux to autoconfigure eth0?

loganb
  • 141
  • 1
  • 4

3 Answers3

1

The short answer: On a system that you are running radvd on, you want to configure the interface using the same method as you use to configure radvd; if radvd.conf is statically generated, then so should your local Ethernet interface's IPv6 address be statically generated. But, all is not lost; read on for more detail.

What you can do is use a small shell script to configure both. Let's say for a moment that you have a dynamically assigned global IPv4 address, and this is the only IPv4 address on your interface; you can use the following shell script snippet to obtain the IPv6 /48 prefix (note: code adapted from ARIN:

IPV4=$(ip addr ls eth0 | grep 'inet ' | awk '{ print $2 }' | cut -f1 -d/)
PARTS=`echo $IPV4 | tr . ' '`
PREFIX48=`printf "2002:%02x%02x:%02x%02x" $PARTS`

Now, you have the /48 prefix; getting a /64 prefix is simple enough, since you can just append it to the $PREFIX48 variable.

Now, all that would be left for you to do is write the script that writes out the network interface configuration and radvd configuration (presumably, from a template for each of them) and make that script run before your network configuration does. I'll not be including that code here as I do not know what distribution you are using, and it differs depending on that.

Hope this helps.

Michael Trausch
  • 289
  • 1
  • 7
0

I'm not sure. But if your MAC address and the prefix you use don't change, why not statically configure the interface with the address that would otherwise come from auto-assignment?

If your MAC address or prefix do regularly change, I'm curious to know what you're doing.

0

What's your router running? If it's a full-blown distribution like Gentoo, OpenRC has a /etc/conf.d/net:6to4_suffix setting, and if #357929 gets fixed the way that's been proposed, Debian will have a /etc/network/interfaces:6to4subnet setting too.

Otherwise, I would just set the address manually. A script on my router contains something like this:

IDEV=br0
ODEV=vlan2
WANIP=`ip -4 addr show dev "$ODEV"|awk '/inet /{print$2}'|cut -d/ -f1`
V6PREFIX=`printf '2002:%02x%02x:%02x%02x' ${WANIP//./ }`
V6NET=16
GW=192.88.99.1

ip tunnel add 6to4 mode sit remote any local "$IP" ttl 255 dev "$ODEV"
ip link set 6to4 up
ip addr add "$V6PREFIX::1/$V6NET" dev 6to4
ip addr add "$V6PREFIX:1::1/$((V6NET+48))" dev "$IDEV"
ip route add 2000::/3 via "::$GW" dev 6to4 metric 1

I guess you want $V6PREFIX:dead::1/$((V6NET+48)) or something like that.

ephemient
  • 1,420
  • 1
  • 11
  • 8