Proper training and guidance....
When introducing a new dog to our chickens I use a shock collar. Never let the dog associate the control with the collar, they assume it's coming from the chickens and learn to leave them alone.
You must command train your dog on leash first, any dog that has bad habits on leash will be uncontrollable off leash. If you have to repeat yourself your dog needs more work.
Some of the timeframes listed here are very long and honestly just not true. I have never had a dog that wasn't house broken in 10 days or less, you can train a dog to do almost anything in a week. Yes that training needs reinforcing and much attention must be given in order to make that possible. 2 years is an unacceptable number as far as I'm concerned. I would never keep a dog that long that couldn't be left unattended. I understand everyone's situation and experience is different, we have been able to train protection dogs in far less time than that. My current dog is a German shorthair that's 11 months old, she's started working unattended with our chickens in mid April. That's right 8 months old! Not only does she guard the chickens, she also guards our children nothing gets by her she is an exceptional dog.
I think a term that's used far too much on these forums is prey drive.... It's almost always used out of context. A dog without it will not be effective. That's what keeps them alert and ready, how can you expect a dog to persue and or attack a predator without it? You can't it's a contradiction.
Dogs are far smarter they they get credit for, anything that ventures into our perimeter is in serious trouble. Yet she understands perfectly that chickens are off limits, she treats them and my kids about the same. Always watching.
Dogs need to be treated like dogs, not people. I think this is one of the biggest mistake people mistake while trying to train their dogs. If you are stern and swift with correction the dog will understand much faster, you also have to be extremely consistent anything else creates bad habits and that's going backwards.
You need a relatively good dog and very much discipline on your part to work with them. You also need to take the time and train them right, if you do that your dog will be a rockstar.