We give exact and explicit expressions of mean first-passage times for random walks in a rectangular domain in both cases of reflecting boundary conditions and periodic boundary conditions. The situations with one or two absorbing targets are considered.