Execution of distributed denial-of-service (DDoS) attacks requires little effort on the attacker's side, since a vast number of insecure machines provide fertile ground for attack zombies. These attacks can easily be downloaded and deployed. On the other hand, prevention of the attack or the response and trace back of agents is extremely difficult due to a large number of attacking machines, the use of source-address spoofing and the similarity between legitimate and attack traffic. The objective of this work is to develop algorithm that will help optimal placement of guard node (GN) in different network topologies. If we use all nodes in the networks as Guarding nodes (GN), then the overall efficiency of the network as well as the energy of nodes will decrease rapidly. We study how to optimize the placement of these nodes so that they can detect DDoS attack on earliest, while using minimum number of GN, and keep the cost factor and overhead as low as possible with minimal energyutilization.