Leiningen's main defense against the ants is a moat, designed to fill and empty with water to drown and wash away the ants. Instead of just being filled with water, it can be opened and closed, so the ants won't fill it with their bodies.
...by opening the dam, he was able to fling an imposing girdle of water, a huge quadrilateral with the river as its base, completely around the plantation, like the moat encircling a medieval city. Unless the ants were clever enough to build rafts. they had no hope of reaching the plantation, Leiningen concluded.
(Stephenson, "Leiningen Versus the Ants," classicshorts.com)
However, through their enormous number, the ants are able to form bridges of a sort with their bodies, stuck together and drowned. He also uses gasoline sprayers both to set large patches of earth alight, to burn the ants, and to flood the moats when it is empty to burn the ants before they can make it over. The plantation workers use shovels to throw dirt into the ants to scatter them, and uses other canals to reroute the ants into expendable fields.