We propose a general methodology for calculating the self-diffusion tensor from molecular dynamics (MD) for a liquid with a liquid−gas or liquid−solid interface. The standard method used in bulk fluids, based on computing the mean square displacement as a function of time and extracting the asymptotic linear time dependence from this, is not valid for systems with interfaces or for confined fluids. The method proposed here is based on imposing virtual boundary conditions on the molecular system and computing survival probabilities and specified time correlation functions in different layers of the fluid up to and including the interfacial layer. By running dual simulations, one based on MD and the other based on Langevin dynamics, using the same boundary conditions, one can fit the Langevin survival probability at long time to the MD computed survival probability, thereby determining the diffusion coefficient as a function of distance of the layers from the interface. We compute the elements of the diffus...