It's only illegal if it goes over the fence, just saying. If you have the permission of the landowner, you can shoot just about anything on the property provided the projectile doesn't leave the property.
Doesn't matter if it's a BB gun or a shotgun, same rule applies.