Due to the shortage of medical resources, insufficient time and inconvenient travel, many patients can not get timely diagnosis or treatment. In this paper, a model named MKMed (knowledge-aware memory networks-based medical dialogue generation model) is proposed. It incorporates professional medical external knowledge to generate response. Concretely, the proposed model first tracks knowledge entities from dialogue history by exact word matching. Next, it performs a two-stage prediction in the external knowledge base to select medical entities and corresponding knowledge, which can be used in generating response. The two-stage prediction mainly uses methods for calculating co-occurrence matrix and cosine similarity between entities. Then it uses memory networks to store the information of knowledge and history. Finally, MKMed generates responses incorporating the stored information in the memory networks and uses recurrent neural network with attention mechanism. Experiments are carried out on a large-scale medical dialogue dataset with external knowledge, KaMed, which is a realistic dataset collected from the online platform. The experimental results indicate that the proposed model, MKMed, is significantly superior to the most baselines in terms of fluency, diversity, correctness and professionalism of response generation. This paper reveals that importing external knowledge with rational devised method is helpful for generating more precise and meaningful response.