A wireless sensor network (WSN) consists of distributed sensors for monitoring network status and recording data, which is playing a major role in Internet of Things (IoT). This type of wireless network is driven by the availability of inexpensive and low-powered components. However, WSN is vulnerable to many kinds of attacks like Distributed Denial of Service (DDoS) due to its dispersed structure and unreliable transmission. In the literature, constructing a suitable distributed packet filter is a promising solution to help mitigate unwanted traffic. While how to ensure the integrity of exchanged data is a challenge as malicious internal node can share manipulated data to degrade the effectiveness of filtration. In this work, we design a blockchain-based blacklist packet filter with collaborative intrusion detection that can be deployed in WSNs. The blockchain technology is used to help build a robust blacklist for reducing unwanted traffic. In the evaluation, we investigate the performance of our filter with a real dataset and in a practical WSN environment. The results demonstrate that our proposed filter can enhance the robustness of blacklist generation.