Routing is a key component for building an interconnected network architecture. There are inter-domain and intra-domain routing protocols. The inter-domain routing protocol has experienced increasingly frequent anomalies, such as IP prefix hijackings, route leaks, or impact from large-scale disruptive routing events. The intra-domain routing also suffers from various attacks originated from within an autonomous system, such as topology manipulation and host-based flooding attack. Security upgrades to the existing protocols and accurate detection mechanisms have therefore been proposed and experienced. In this study, we conduct a comprehensive survey on the existing security mechanisms for both inter-domain and intra-domain routing protocols. For inter-domain routing protocol, we study the de facto protocol – Border Gateway Protocol (BGP). For intra-domain routing protocol, we investigate the recent software-domain networking paradigm and the OpenFlow protocol. For each routing protocol, we investigate both attack prevention solutions and attack detection solutions. We summarize the strengths and weaknesses of every existing solution, and discuss the missing gaps that need further research.