We propose a simple and reliable method to measure the liquid crystal surface anchoring strength by molecular simulation. The method is based on the measurement of the long-range fluctuation modes of the director in confined geometry. As an example, molecular simulations of a liquid crystal in slab geometry between parallel walls with homeotropic anchoring have been carried out using the Monte Carlo technique. By studying different slab thicknesses, we are able to calculate separately the position of the elastic boundary condition, and the extrapolation length.