In DC microgrids, classical generators in traditional power grid are replaced by converter-interfaced distributed generation (DG) or energy storage systems (ESSs) and rotating inertia cannot be directly connected. This causes a reduction of the total inertia of the system. Therefore, the DC microgrid voltage becomes more sensitive under load variations and power fluctuation from the intermittent distributed energy sources. In this paper a virtual-impedance control is designed for DC microgrids, which provides the system with synthetic inertia. In proposed strategy, the rate of change of voltage (RoCoV) can be decreased by virtualcapacitor part, transient and steady-state behavior of the converter under load variations can be defined by varying the virtual-inductance and virtual-resistance, respectively. Stability of the proposed strategy is analyzed by looking at the dominant eigenvalues of the small-signal model. The simulation results indicate that the proposed method with virtual impedance improves the transient response.