The industrial internet of things (IIoT) is considered a new paradigm in the era of wireless communication for performing automatic communication in the network. However, automatic computation and data recognition may invite several security and privacy threats into the system during the sharing of information. There exist several intrusion detection systems (IDS) that have been proposed by several researchers. However, none of them is able to maintain accuracy while identifying the threats and give a high false-positive rate in the network. Further, the existing IDS are not able to recognize the new patterns or anomalies in the network. Therefore, it is necessary to propose a new IDS. The aim of this paper is to propose an IDS using the Viterbi algorithm, indirect trust, and blockchain mechanism for IIoT to ensure the required security levels. The Viterbi algorithm and indirect trust mechanism are used to measure the probability of malicious activities occurring in the network while generating, recording, and shipping products in an IIoT environment. Further, the transparency of the system is maintained by integrating blockchain mechanisms with Viterbi and indirect methods. The proposed framework is validated and analyzed against various security measures by comparing it with the existing approaches.