I used partly your script and it works for the directions it should, thank you for this. But PREROUTING has nothing to do with local-to-remote packets, it's OUTPUT chain (last part of Chapter 10 in your link) . And for OUTPUT fwmark doesn't work in my case, would be good to know if it works for you.