Replies: 8 comments 3 replies
-
You may find this codelab helpful https://openthread.io/codelabs/openthread-border-router-nat64 |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
The nat64 prefix is derived from the ULA prefix which is saved in persistent storage, so it should survive reboots (changes only when the BR is factory reset). |
Beta Was this translation helpful? Give feedback.
-
Interesting I'll have to test it again, so would it change if you ran |
Beta Was this translation helpful? Give feedback.
-
Yes, if |
Beta Was this translation helpful? Give feedback.
-
Apologies late i've been away. That sounds like the reason the address is changing then, as we run this at the start of our script. I suppose my final question is: Cheers. |
Beta Was this translation helpful? Give feedback.
-
I've wrote a small function to find the first nat64 prefix on the network, or else fall back to the default 64:ff9b:: . As older versions of BR don't add this nat64 route + flag (from memory, i could be wrong?). I think a few people may be in my position in the future, so I've posted the function below. Disclaimer, it's completely untested at the moment and wrote for Zephyr 3. /**
* Find the first NAT64 prefix on the network and save it to settings
*
* Example results:
* - fdea:5eab:2b32:2:0:0:
* - fdea:5eab:0b11::
*/
void openthread_controller::find_nat64_prefix()
{
otNetworkDataIterator iterator = OT_NETWORK_DATA_ITERATOR_INIT;
otExternalRouteConfig config;
// Lock openthread api
openthread_api_mutex_lock(openthread_get_default_context());
// Get the default instant as we only use one
otInstance* ot_instance = openthread_get_default_context()->instance;
// Loop through all routes to find a nat64 prefix
bool found_nat = false;
while (otNetDataGetNextRoute(ot_instance, &iterator, &config) == OT_ERROR_NONE)
{
// If the current route is a nat64 prefix
if(config.mNat64)
{
// Mark that a nat prefix was found
found_nat = true;
// Get the prefix into a string form
char string[OT_IP6_PREFIX_STRING_SIZE];
otIp6PrefixToString(&config.mPrefix, string, sizeof(string));
auto prefix = std::string(string);
// Remove the prefix length (/32, /64, /96 etc) if present
if(prefix.find('/') != std::string::npos)
{
prefix.erase(prefix.size() - 3);
}
// Remove the last `0:0` if `::` is not found as we are creating a prefix
if(prefix.find("::") == std::string::npos)
{
prefix.erase(prefix.size() - 3);
}
// Save the prefix in settings and break (@todo save multiple nat64 prefixes)
settings::device::set_nat64_prefix(prefix);
break;
}
}
// If a nat was not found we'll assume the default prefix of 64:ff9b::
if(!found_nat)
{
settings::device::set_nat64_prefix("64:ff9b::");
}
// Unlock thread api
openthread_api_mutex_unlock(openthread_get_default_context());
} |
Beta Was this translation helpful? Give feedback.
-
Hi,
I've setup a few board routers in the past which have been working fine. However I'm trying to setup some new BRs with 'main' branch.
It seems like the way the IPv6->IPv4 NAT feature is implemented has changed.
Differences
Interface
When i setup the new border router on a RPI, i no longer get the NAT64 interface, like i use to
Required Commands
I've also noticed a new command
ot-ctl nat64
. As such I've modified our startup script to includeot-ctl nat64 enable
This command then adds a route onto the network, as can be seen by
netdata show
.Can this IP address be fixed to a known address, as it changes on every boot cycle?
Global Prefix
In the past we registered a global prefix
sudo ot-ctl prefix add 2001:dead:beef:cafe::/64 paros
in our startup script.Hence to access an external IPv4 address we'd simple use
64:ff9b::808:808
for8.8.8.8
for example. However this no longer works.Summary
What do we need to do in order to have a functional NAT again? Is there a summary of what has changed?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions