Software‐defined networks are a modern architecture in computer networks where traffic transfer is separated from network control. In software‐defined networks, all decisions are made in the controller, and the necessary commands are injected into the network equipment. With the advent of software‐defined networks and the introduction of a new concept called controller in these types of networks, it becomes important to find an appropriate location for the controller and its number in the network. This problem aims to find the location and the optimal number of controllers needed in the network, and how to assign switches to the controllers declined certain constraints. In this article, a method to determine the appropriate location for controllers is proposed, so that the cost of network implementation would be reduced and thus its survivability is improved. Finally, we analyzed the proposed method in terms of evaluation criteria. With the advent of software‐defined networks and the introduction of a new concept called controller in these types of networks, it becomes important to find an appropriate location for the controller and its number in the network. This problem aims to find the location and the optimal number of controllers. In this paper, a method to determine the appropriate location for controllers is proposed, so that the cost of network implementation would be reduced and thus its survivability is improved.