What is the best way to stop my fenced-in dog from barking at people who are passing by on the street?
This is a very tricky problem for the simple fact that your dog gets rewarded every time it barks at a passerby. In the dog's head, it's all very simple.
Person approaches, dog barks, person leaves.
Yay to the power of barking!
Depending on the size of your garden, if none of TildalWave's suggestions are an option, you might have to temporarily keep your dog in the house while you're not at home and in a room that doesn't allow him to bark at passersby through the window.
The long-term approach is to use desensitisation and counter-conditioning, that is, slowly get your dog used to strangers coming near the fence and start to associate strangers with good things happening(TM).
You'll have to recruit some strangers (to your dog) and ask them to approach the fence to a distance that your dog is comfortable with. Reward your dog for noticing the stranger but not barking at it. Slowly move the dog and/or stranger closer together and keep rewarding good behaviour. Try to set your dog up for success as much as possible. The less often you get your dog's threshold wrong, the quicker it'll learn.
Also, it is very important for the stranger not to move away if your dog does start barking, as this will only reinforce the unwanted behaviour. Just ask the person to stay still and move your dog further away from the fence. Most of all, exercise plenty of patience as it might take a while.
Dogs are territorial and will protect their area whenever there is some natural or an artificial border separating their territory from not their territory. Most of them aren't too aggressive at that tho, and if you opened the fence doors you'd likely observe your dog bark while a passer by walks next to the fence, and stop soon after they pass by the open door. That might not be possible to do in your case, but you have probably observed this behaviour previously with other dogs behind fences.
I'm describing this to somewhat lower your expectations, because you're unlikely to stop your dog barking at passers by when they approach some barrier they learned to protect, adopted as their territory. When I say learn, large part of this behaviour would be preconditioned and greatly depends on the dog species, and when I say their territory, some dog species that are more lenient to strangers approaching might be more permissible in all of this.
So one way to prevent that would be distancing your dog from the fence itself, maybe by building a kennel within that fence but far enough from it for the dog to feel comfortable with strangers passing by (it would depend on each individual dog really, even their pecking order if you have more than one), but I would advise against chaining your dog or anything of that sort, not to cause it further inconvenience. The dog is really merely doing its job when barking at strangers. And strangers here means any passers by that the dog didn't yet successfully identify on their approach. Different dog breeds will have different sight, smell and hearing abilities, so this will vary too.
Alternatively, if at all possible, move your fence to be slightly protruding onto the street, at least a bit more than your neighbour's so the dog can see, smell and hear incoming passers by before they nearly brush against your fence and surprise your dog, making it bark even more vigorously. Or even the other way around, recess your fence inwards so there's enough of space between the pathway beyond the fence and the fence itself. Anyway, there are many ways to help prevent or lower the frequency of this barking through the fence, once you know where this behavior originates from.
Observe your dog, allow it to move freely on your lawn and take a mental note of when the dog doesn't feel threatened by passers by, and when it does. Then apply these rules learned to whatever would keep your dog from barking through the fence. Some breeds tend to be more nervous while others might be easier to apply any of these rules to and mitigate this problem. Terriers are particularly territorial (not where the name comes from, tho), also shepherds but usually when there's something else than themselves to protect within the protected area, and some hounds or similar might not even give any attention to passers by. As a general rule of a thumb though, bigger dog breeds tend to be more confident in themselves and be slower, less energetic in their reactions to strangers. Unless they feel they really have to. So, learn your dog's ways and you two will work together on it, figure it out. ;)
Get an old 12 oz soda can rinse it out then place around 10 pennies inside of the can, and tape it off at the mouth. I find electrical tape or silver duct tape works the best. Now that you have that finished the next steps are the most important. The next time you are out front with your dog and a person approaches your fence whether they are by themselves or walking their own dog and your dog starts barking, you take the soda can and under toss it gently towards the general direction of your dog. DO NOT throw it at your dog!
The purpose of this is NOT to hurt your dog but to startle your dog instead. It's to snap them out of the "bad" behavior that they're doing and get them focused on something else other than the passerby. In a sense it's like resetting their brain. The noise the can with pennies will make is loud thus triggering their brains to forget about what they are doing at the time. When your dog stops barking at the person is when you want to give positive praise and or a treat for their good behavior. As time progresses your dog will associate his/her (in our minds negative behavior of) barking with a loud sound that he/she doesn't like and eventually the barking will cease.
Just remember to toss, NOT throw the can in the direction of your dog, NOT at your dog. This technique has worked for every dog I've ever owned and my friends dogs as well. And believe it or not... none of them are scared of soda cans! Good luck and I hope this helps you and your dog with the barking issues at hand.