This should probably go under other pets and livestock.... But I happen to train dogs and it's not as hard as people think.
Part of this depends on your breed of dog. A border collie for example is a smart dog who wants to please so when he gets shocked you scold him gently and he should leave well enough alone. A husky on the otherhand has no concern for you, the ducks or itself and just wants what it wants. They're far more persistant and have a very high pain tolerance so one shock and a scolding isn't really enough.
The first thing to do is find a treat your dog goes BONKERS for. I have two dogs who are not food driven and have mild grain allergies (like most dogs do) so I use very specific treats. Boneless skinless chicken breasts (dehydrated, jerked, freeze dried or boiled) torn up small are a good treat that's healthy that dogs go nuts for. When I am lazy I like to use Bil-Jac Liver Treats and they enjoy those quite a bit and there's these "omega-3" salmon and sweet potato things I use when I can find them. Other forms of natural whole-meat are pretty appealing too... If all else fails crack open a can of tuna or a jar of peanut butter. You want something they love more than anything and is small and fast to eat.
Once you have that one thing (or things since it's good to mix it up) the dog wants work on some basic commands like the standard "sit down stay". Use normal treats. Do this in various areas not just inside but outside, on walks, everywhere you can. Then work on "leave it" the same way. This is done by holding or waving something the dog wants (like a treat or toy) in front of their face and when they try to take it from you pull it away from them and in a deep and firm voice say "LEAVE IT." You don't need to shout but you need to sound in-charge and deep voices tend to work better than the hysterical screams people get when they shout. You can also grab their snout and hold it closed if they still don't get it. Most dogs don't need this and respond well without it. When the dog stops going after the object, praise it and offer it the super high motivating treat.
Once your dog have the basics of "leave it" down you can teach your dog to leave anything through similar means, though some things are easier than others. For example I can get one of my dogs to leave squirrels, birds, other dogs, cats and rabbits alone... The moment she sees a ferret everything changes. With this in mind I wouldn't directly teach your dog to "leave" the ducks but would instead teach the dog to first "leave" the FENCE by putting something super appealing behind it. Then just make leaving the fence a little more challenging by adding the ducks. The dog will already know not to mess with the fence just because something they want is behind it. But I wouldn't ever trust the dog unsupervised by the fence.
http://www.dogster.com/dog-training/dog-commands
There's a pretty good list of various dog commands and how to get them to preform them.