Use address in “Routed IPv6 Prefixes” as default outbound address when using HE.net’s tunnel broker

By default Linux (randomly?) chooses “Client IPv6 Address” (given by HE.net) as source address for outbound connections. This can be inconvenient sometimes tough.

To override this, it’s possible to add a new address in “Routed IPv6 Prefixes” to eth0 in /etc/interfaces.d/eth0 …:

iface eth0 inet6 static
  address 2001:db8::1/64

… and abuse the definition of an IPv6 home address to override this with:

ip addr change 2001:db8::1 home dev eth0

To persist it, one can add a post-up command in /etc/network/interfaces.d/eth0:

# ...
iface eth0 inet6 static
  address 2001:db8::1/64
  post-up /sbin/ip addr change 2001:db8::1 home dev eth0

Edit: At first I tried to add a script to /etc/network/if-up.d with:

#!/bin/bash
set -e

/sbin/ip addr change 2001:db8::1 home dev eth0

It leads to failure in starting networking.service with RTNETLINK answers: File exists, though. I think the reason it failed was that I should have tested interface name before setting the address as home address. Using post-up command saves life here.

Leave a Reply

Your email address will not be published. Required fields are marked *