Is it possible to write a firewall in python? Say it would block all traffic?
Because implementing a system is the best way to understand its underpinnings. we have implemented a firewall using Python and some Netfilter tools. Before going into the details of our implementation, we should give some background on TCP, the Netfilter project, pythonnetfilterqueue, and IPTables.
The firewall algorithm was implemented using Java programming language, which was based on java security architecture. It also utilizes the concept of socket programming which enables network communication over the internet.
The Linux kernel includes the Netfilter subsystem, which is used to manipulate or decide the fate of network traffic headed into or through your server. All modern Linux firewall solutions use this system for packet filtering.
I'm sure in theory you could achieve what you want, but I believe in practice your idea is not doable (if you wonder why, it's because it's too hard to "interface" a high level language with the low level kernel).
What you could do instead is some Python tool that controls the firewall of the operating system so you could add rules, delete , etc. (in a similar way to what iptables does in Linux).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With