What is the best way to protect yourself from dogs walking?

Be confident. Dogs, like all pack animals, respond to fear or confidence. Be confident and most dogs will leave you alone. Try to avoid eye contact with them, and if you cannot, command them with a loud command.