From 866e8f2145f0cb01db75c824907ae6a09f198cc4 Mon Sep 17 00:00:00 2001 From: Marcel Hofer <3976393+mhofer117@users.noreply.github.com> Date: Mon, 25 Jan 2021 19:18:51 +0100 Subject: [PATCH] fix issue #4025: 6rd with single /64 prefix (#4635) Builds upon the 6rd routing fixes discussed in https://forum.opnsense.org/index.php?topic=20260.0 Instead of setting the calculated /64 subnet length on the _stf interface, I set the original ISP provided subnet length. And change the gateway to be inside the ISP provided prefix instead of the calculated /64. wan address will still be the same but the wider subnet solves any routing issues with single /64 prefixes --- src/etc/inc/interfaces.inc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 0b0959ad1..95e5be5f2 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -2721,6 +2721,7 @@ function interface_6rd_configure($interface = 'wan', $wancfg) /* create the long prefix notation for math, save the prefix length */ $rd6prefix = explode("/", $wancfg['prefix-6rd']); + $rd6prefix_isp = $rd6prefix[0]; $rd6prefixlen = $rd6prefix[1]; $rd6prefix = Net_IPv6::uncompress($rd6prefix[0]); @@ -2737,7 +2738,8 @@ function interface_6rd_configure($interface = 'wan', $wancfg) /* convert the 128 bits for the broker address back into a valid IPv6 address */ $rd6prefix = convert_128bit_to_ipv6($rd6prefixbin); - $rd6brgw = "{$rd6prefix}{$wancfg['gateway-6rd']}"; + /* use gateway inside original prefix to avoid routing issues */ + $rd6brgw = "{$rd6prefix_isp}{$wancfg['gateway-6rd']}"; $stfiface = "{$interface}_stf"; if (does_interface_exist($stfiface)) { @@ -2752,7 +2754,8 @@ function interface_6rd_configure($interface = 'wan', $wancfg) } legacy_interface_mtu($stfiface, $mtu); - mwexecf('/sbin/ifconfig %s inet6 %s/%s', array($stfiface, $rd6prefix, $rd6prefixlen + 32 - $wancfg['prefix-6rd-v4plen'])); + # use original prefix length for network address to avoid setting the same subnet as on the LAN side (/64 prefix) + mwexecf('/sbin/ifconfig %s inet6 %s/%s', array($stfiface, $rd6prefix, $rd6prefixlen)); mwexecf('/sbin/ifconfig %s stfv4br %s', array($stfiface, $wancfg['gateway-6rd'])); mwexecf('/sbin/ifconfig %s stfv4net %s/%s', array($stfiface, $ip4address, $wancfg['prefix-6rd-v4plen']));