Get a physical fence or an electronic fence. If you take the dog for a walk, do it only on leash, no exceptions.
Don’t do the electric fence. I saw a show on a dog that was startled and it went through the electric fence. However, everytime it tried to return it would get a shock. It ended up dying on the street because it couldnt get home.
All dogs should be on a leash when walking. Trainer said a dog may interpret a person coming at them & tripping towards you as aggression and with a leash, you can pull them off.