The easiest way is to have your dog wear a shock collar when inside the fence and then use positive reinforcement when he goes outside of the wall. This can teach him that going outside his fence is undesirable and that staying inside is good.