Security and privacy are greatly enhanced by intrusion detection systems. Now, Machine Learning (ML) and Deep Learning (DL) with Intrusion Detection Systems (IDS) have seen great success due to their high levels of classification accuracy. Nevertheless, because data must be stored and communicated to a centralized server in these methods, the confidentiality features of the system may be threatened. This article proposes a blockchain-based Federated Learning (FL) approach to intrusion detection that maintains data privacy by training and inferring detection models locally. This approach improves the diversity of training data as models are trained on data from different sources. We employed the Scaled Conjugate Gradient Algorithm, Bayesian Regularization Algorithm, and Levenberg-Marquardt Algorithm for training our model. The training weights were then applied to the federated learning model. To maintain the security of the aggregation model, blockchain technology is used to store and exchange training models. We ran extensive testing on the Network Security Laboratory-Knowledge Discovery in Databases (NSL-KDD) data set to evaluate the efficacy of the proposed approach. According to simulation results, the proposed FL detection model achieved a higher accuracy level than the traditional centralized non-FL method. Classification accuracy achieved by the proposed model was 98.93% for training and 97.35% for testing.