While they often evoke images of prisons and military bases, electric fences are most commonly used as an efficient, non-lethal way to manage free-range livestock and keep wolves, bears and big cats out of grazing land. Battery-operated electric fences are simple enough to build, but are most effective as an animal deterrent. There are far better options for home security.
Electric fences are basically regular wire fences with a battery and energizer attached. Start by installing posts -- 10 cm (4 inches) wide, if wooden -- along the boundary of your property, roughly 15 to 19.5 m (49 to 64 feet) apart. The holes for each post should be about 90 cm (3 feet) deep. DIY suppliers sell tools called "post augers" specifically for digging these holes. Make the job go faster by renting a backhoe or skid steer loader equipped with an auger attachment. Otherwise, you can use a manual or motorised auger. Ideally, each post should be perpendicular with the ground and stand just over 1.2 m (4 feet) tall. If you want to make a gate anywhere along the fence, measure out the door's estimated length and install posts next to it on both sides.
Ties and insulators
The posts at the ends of the fence and on either side of the gate(s) need to have wire ties installed. The number of ties you install depends on the number of rows you want your fence to have; four lines is ideal, but three is adequate. The wire ties consist of 60 cm (2 feet) of 12.5 gauge high-tensile wire. At one end, the wire loops around the post once and is tied off with a "double half-hitch" knot. At the other end, the wire it tied to an "end strain insulator" with a double half-hitch. Space the four ties evenly up each post. Note: for a diagram, see the link in Resources. Next, install four post insulators along each of the middle posts (i.e. not ends or gates) so they are parallel with the wire ties. Thread a 12.5-gauge wire through each row of post insulators. Finally, tie the end of each threaded wire to the appropriate strain insulator on the end/gate posts, again using a double half-hitch. You should now have a completed wire fence consisting of three or four parallel, separate rails.
At each end/gate post, attach a vertical wire linking each rail to the one below it. Note: the strain insulator should be between the vertical wire and the post.
Next, attach a double-insulated wire (12 or 15 gauge) to the top rail wire, between the strain insulator and where the vertical wire touches. For gates, run the insulated wire down the side of the post and dig a 30 cm (12 inch) deep narrow trench across the opening to the adjacent post. Lay the insulated wire along the bottom and attach it to the bottom rail of the adjacent post. Again, make sure that wire attaches between the bottom rail's strain insulator and the vertical wire. Bury the insulated wire in the trench. At the end posts, attach insulated wiring using the same "top-rail-bottom-rail" pattern as with the rest of the posts. However, instead of joining the end posts with a single, buried insulated wire, attach a separate wire to each post. Connect the unattached end of bottom rail wire to the negative/black terminal of the energizer you purchased. Then, connect the unattached end of the other post's top rail wire to the positive/red terminal. To electrify the fence, connect the energizer's voltage input terminals to a 12-volt "deep cycle" or "motive" rechargeable car battery and switch on the energizer.