The rapid growth of employing devices as tools in daily life and the technological revolution have led to the invention of a novel paradigm; the Internet of Things (IoT). It includes a group of ubiquitous devices that communicate and share data with each other. In order to communicate, these devices use protocols, and in particular, theInternet Protocol (IP) is used to manage network nodes through mobile ad hoc networks (MANET), which provide self-configuring and transient infrastructures. MANET enables each node to freely join or leave the network frequently. IoT is beneficial to MANET as the nodes are self-organising and the information reach can be expanded according to the network range. Due to the nature of MANET, such as dynamic topologies and no administrative point, a number of challenges are inherent, such as message fabrication, confidentiality violations, and Denial of Service (DoS) attacks. DoS attacks prohibit legitimate users from using or accessing their authorised services and is particularly pertinent in IoT systems which rely on persistent connections for the transfer, collection, and processing of data. In addition, because of the high mobility of MANET, the network is likely to merge with other networks. In this situation, two or more networks of untrusted nodes may join one another leaving each of the networks open to attack. This paper proposes a novel method to detect DoS attacks immediately prior to the merger of two MANETs. To demonstrate the applicability of the proposed approach, a Grayhole attack, a type of DoS attack, is used in this study to evaluate the performance of the proposed method in detecting attacks.