First off all, the camera and lens must be on manual focus. You can set the focus to infinity. An exposure value of a few seconds should be enough for night time lightning photography. You can set the aperture between f/4 and f/8. For day time lightning photography, you may choose a shorter exposure value. Please keep in mind that a lightning stays visible for about half a second, so you can consider using a ND filter.