Electric fencing, and/ or dogs.
Shooting a critter with a pellet gun or BB gun is considered animal abuse many places, it causes injuries, pain, and infections, not good.
Many of us don't have good areas where it's safe to use projectile weapon, with neighbors, the road, and our own animals in the field of fire. When possible, a 22 is effective, although it makes more sense to have electric fencing (if legal) and a dog or two.
Foxes are smart and hard to live trap, and should only happen if you plan to then shoot.
Mary