Obviously, there are certain circumstances where you will want your dog to bark at strangers. For example, if you have an intruder in your home, you will want your dog to alert you to their presence or scare them off. You do not want your dog to be friendly or welcoming to everyone without exception, but it is also important that they not view all strangers as threats.
Harnessing your dog's natural vocalization with "speak" and "quiet" commands is an important part of basic training. Expose your dog to whatever stimulates them to bark. Give them the "speak" command. Let them bark, then offer praise and a treat. Repeat until your dog is able to speak on command. Next, you will teach the "quiet" command in much the same way, namely, by offering treats, using a clicker, and praise when they stop barking. Repeat until your dog understands exactly what you want them to do.
To help them associate the commands with strangers, introduce your dog to a stranger and issue the "speak" command followed by the "quiet" command.
You can reward calm behavior when meeting strangers by gradually getting your dog accustomed to new people. Arrange a situation where your dog is exposed to strangers. The more, the better. Have them give your dog treats. This will help to make him or her friendlier and less likely to bark at unfamiliar people.
Be sure to keep how your dog feels in mind during these exercises. For example, if your dog is barking because they are excited or over-stimulated, these training sessions are a great way to control the barking. If your dog is barking out of fear you don't want to force them into an overcrowded environment because this can lead to aggressive behaviors due to fear.
Tired dogs are less prone to excessive barking. Excessive and inappropriate barking is often the result of stress from getting too-little exercise. More walks or even agility training may be necessary.
Your dog can interpret your emotions very well and they are likely to reflect it. As irritating or frustrating as a noisy dog can be, expressing your irritation or frustration can make matters worse as your dog may adopt your state of mind and express it with even more barking. It is important to compose yourself before correcting your dog and to communicate in a calm and measured tone.
Yelling at your dog to stop barking can sometimes cause them to continue to bark because now they feel that you are engaging in the "fun" with them.
Dogs bark at people and animals they do not know, this is natural; however, that instinct to bark can be controlled. The steps above can help you to take control of how your dog reacts to strangers.