Internet of Things is made up of sensor nodes that can sense the given environment, gather the data from environment and then communicates the data to the sink node and the internet through wireless communication. As it follows the routing protocols used in Wireless Sensor Networks, the Denial of Service (DoS) attacks including selective forwarding and flooding are launched by the attackers through Routing Protocol for Low-Power and Lossy Network (RPL) attacks. Intrusion detection systems are able to handle the RPL based DoS attacks and can prevent the attackers from participation in the routing process. Therefore, we propose a new fuzzy temporal random forest algorithm for detecting the attacks more efficiently. In addition, a new intelligent agent based intrusion prevention system which uses fuzzy temporal inference rules for intrusion prevention is also proposed in this work. The proposed model has been compared with other machine learning algorithms such as decision trees, logistic regression, random forest, K-Nearest Neighbor and also the deep learning algorithm namely the Convolution neural networks. Based on the experimentations carried out, we could prove that the proposed algorithm provides higher intrusion detection accuracy, reduces the false positive rate and detection time when compared with the related work.