select mesh local address (#1734)

diff --git a/src/core/net/ip6.cpp b/src/core/net/ip6.cpp
index 16a610e..d9d43dd 100644
--- a/src/core/net/ip6.cpp
+++ b/src/core/net/ip6.cpp
@@ -1021,6 +1021,30 @@
                     rvalPrefixMatched = candidatePrefixMatched;
                 }
             }
+            else if (rvalAddr->GetScope() == Address::kRealmLocalScope)
+            {
+                // Additional rule: Prefer appropriate realm local address
+                if (overrideScope > Address::kRealmLocalScope)
+                {
+                    if (rvalAddr->GetAddress().IsRoutingLocator())
+                    {
+                        // Prefer EID if destination is not realm local.
+                        rvalAddr = addr;
+                        rvalIface = candidateId;
+                        rvalPrefixMatched = candidatePrefixMatched;
+                    }
+                }
+                else
+                {
+                    if (candidateAddr->IsRoutingLocator())
+                    {
+                        // Prefer RLOC if destination is realm local.
+                        rvalAddr = addr;
+                        rvalIface = candidateId;
+                        rvalPrefixMatched = candidatePrefixMatched;
+                    }
+                }
+            }
             else if (addr->mPreferred && !rvalAddr->mPreferred)
             {
                 // Rule 3: Avoid deprecated addresses