This is really a common problem. It is so common that I have an article written about this which I have included here. After this I'll address your dog's situation itself.
Many dogs have reactions to different noises. This is really a problem around the 4th of July and fireworks. For things like thunderstorms, some people tape the noise and play it back at lower volumes while playing with the dog and providing positive reinforcement for the dog's lack of anxiety while the noise is played at low volumes. Positive reinforcement would include calm praise and hot dog slices or other tasty treat (not regular treats. You then gradually increase the volume slowly until your dog is desensitized to the noise. A vet could prescribe a medication called Acepromazine, which is a tranquilizer. You can read about this here:
Another prescription drug would be Xanax but I have to say that no one should give any prescription drug to a dog without consulting their vet first.
Many people get Rescue Remedy to help with noise phobias. Be sure you get the kind that does NOT contain Xylitol. You can read about this here:
It may also be available in your local pet store as well. Benadryl is often used as it does tend to calm your dog. Benadryl can be given to your dog, the dose is up to 2mg per pound every 8 hours. Benadryl in not a sedative though so it won't put your dog to sleep. Leaving a TV playing loud also helps prevent your dog from hearing the outside noises. Another treatment is Melatonin which you can read about here. It has been shown to work well for noise phobias.
DAP collars might help a bit as well. They produce pheromones that mimic the ones produced by a nursing mom to calm her pups. It has proven to be helpful with this problem but was used in conjunction with desensitization so it is unknown if the collar or the training was the major factor in resolving the problem.
Now for your dog specifically, the above suggestions should help but you also need to do some other things. You state that you try to distract him. If you show a dog attention or even distract him with food or a treat or even reassure them, that is all positive reinforcement. Positive reinforcement will encourage the dog to continue the undesired behavior. So your really need to ignore the "fear" behavior as much as possible. Many owners will create a safe place for a dog to go to during "thunderstorms" such as a covered crate, or a inner room.
There is a product thundershirt that is pretty good at helping with the behavior short term. Many owners report that it works well if they follow the directions but that after a couple of weeks, it seems to not do as good of a job. This might be a tool to be used while you are desensitizing your dog to the loud sounds of storms.
I hope this information is helpful to you and you are satisfied with my response. If you would like any additional information or have more questions please don’t hesitate to press the reply to expert or continue conversation button so I can address any issues you still have .
Thanks for help, I have since taken him to vets who prescribed diazepam tablets, but still not sure how to handle him when he gets spooked.