With the rapid development of P2P network, free riding has become a serious problem. Controlling free riding is a hot research both in academic and industrial communities. In this paper, a Distributed and Monitoring-based Mechanism (DMM) is proposed to discourage free riding in P2P network. Based on the behavior and function of nodes in the network, the paper makes the network system abstractly as a distributed and monitoring structure focus on avoiding malignant cheating and dishonest behaviors. Through analyzing kinds of factors that effect the nodes' contribution to the whole network, a utility function is defined to determine the useful degree of the nodes and make corresponding treatments to the nodes' service request. Moreover, we introduce reputation to guarantee the QoS and import license to realize the rewards and punishment with nodes in the network. Finally, the effectiveness and feasibility of the model is illustrated by the simulation experiment designed with PeerSim.