The traditional cellular architecture where devices connect to their service base station (BS) may cause poor performance especially for edge users. Device-to-device (D2D) communication enables nearby user as a relay to help BS forward information, thereby improving the network coverage and quality of service (QoS) of edge users. This paper proposes a distance-based D2D matching mechanism for general cellular networks, where a relay user who successfully connects to its targeted BS can transmit data to its closest user for D2D communication. A link of BS to D2D pair contains two sublinks, which occur at different time phases in each cell. Assuming a nonsynchronous system, we consider that there exists cross-layer interference for D2D links. Based on the techniques of stochastic geometry, we develop the performance of coverage probability and ergodic rate of the D2D network. A key intermediate step in this analysis is the derivation of the interference expressions for D2D links caused by BSs and cochannel D2D users. Then, we derive the meta distribution of the signal-to-interference ratio (SIR) to capture the performance changes of individual links. Simulation results demonstrate that our matching mechanism based on the appropriate time resource allocation favors the edge users with a higher probability of successful communication and transmission rate.