When balancing ECMP you need to be a little careful with the traffic. With TCP connections everything works fine. BUT strange things begin to happen in UDP, especially in the DNS.

Juniper hashes ECMP in Layer4 mode with standard settings.

This is where problems with UDP traffic begin. When one client host changes its output port, it gets different servers, and for obvious reasons, each server has its own caches. In some routers, this behavior sometimes causes problems with resolution.

To solve this problem, you need to switch the hashing mode in Layer3.

After switching, traffic from one client address will always go to one specific server, which actually solves this problem.

How to switch:

vitalvas@mx204-city17# show | compare
[edit forwarding-options]
+   enhanced-hash-key {
+       family inet {
+           no-destination-port;
+           no-source-port;
+       }
+       family inet6 {
+           no-destination-port;
+           no-source-port;
+       }
+   }

How to enable ECMP:

vitalvas@mx204-city17# show | compare
[edit policy-options]
+   policy-statement load-balance {
+       then {
+           load-balance per-packet;
+       }
+   }
[edit routing-options]
+   forwarding-table {
+       export load-balance;
+       ecmp-fast-reroute;
+   }