Easiest way when training my own dogs is while they are puppies and mature into dogs, they are only outside while under your supervision and control or in a kennel or run. If they are outside, you are outside with them and they have to do what you say. If you tell them to go somewhere and do something, it has to be done every time, no matter what. In that time also practice what the concept of HOME is...practice making them "Stay Home" while you walk or drive farther away and then come back. Anytime they are caught near the boundary of where they should be....give them a "Stay Home" and make them go back towards the house. Then, slowly, as you trust them, you can start leaving them unsupervised for short, and then longer periods of time as you peek at them through the window. Anytime they are near the boundary or caught off of it.....chew them out a little and put them in their kennel. Took me about 6 months with our current dog, a Cane Corso Mastif, and now he stays "home" really really well. He will sit at the house and whine and bark at me if I am 1/4 mile away at the shop where I work, but he won't come over unless I hollar at him and give him permission. He has always been easy to train though. We also have him completely taught how to deal with strangers driving up. He he sits at the door and waits to be talked to before he decides if they are a good guy or a bad guy. The UPS and mail people love him, he hops up on the truck after they call him, goes on the school bus when invited so the kids can pet and love on him real quick. With a complete stranger he is a really good judge of character. If we greet them warmly he tends to follow our lead, he has decided a time or two that someone didn't pass muster, hair rised right by our sides and low growl. Made him go inside and we interacted and got them off on their way.
Basically the long and the short of it is don't let them decide that they get to go and do whatever they want. Stay in control. If you are going to have a dog off leash and on your property it is still your job to be in control, they have to know exactly what is expected of them before they are allowed to be out on their own conscience.