Well, in my tests, "any to any" pipes hanged all the time. And the "via" setting don't worked well too.
The pipe creation order are a problem too. The manual don't talk about this, but you need to create the pipe before apply the mask. Using the way you are trying, the pipe is created in the first command and again on the second. This can cause the hang on wan, because the mask will be set but the queue don't. Taking a deep look, a saw that the mask combination used in your script you are matching the last byte of wan client address. So if a client with address 64.233.167.99 and other 200.221.2.99 are matched as the same. If you want to fix the bandwidth for a internet address you need to use a full 0xffffffff mask. Otherwise, Pipe 101 and 102 src-ip and dst-ip are in inverse order. I will rewrite your script using my approach either for LAN and WAN. When it´s ok i will send it to you! TIA, Luiz Vaz