diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-02-11 15:58:43 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-02-15 19:25:05 +0530 |
commit | 102429b18255f0364426fd377ac988c3d4624e6f (patch) | |
tree | f5492495989fba5016857f9eaf44da00e0ab210e /src/walu/wall.py |
repo: init
Diffstat (limited to 'src/walu/wall.py')
-rw-r--r-- | src/walu/wall.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/walu/wall.py b/src/walu/wall.py new file mode 100644 index 0000000..18c4594 --- /dev/null +++ b/src/walu/wall.py @@ -0,0 +1,34 @@ +#!/usr/bin/env/python3 + +import subprocess + +class wall: + iface = "" + + def __init__(self, iface = "lan"): + self.iface = iface + + def walu_init(self): + subprocess.run(["iptables", "-A", "FORWARD", "-i", self.iface, + "-j", "REJECT", "--reject-with", "icmp-host-prohibited"]) + + def walu_down(self): + subprocess.run(["iptables", "-D", "FORWARD", "-i", self.iface, + "-j", "REJECT", "--reject-with", "icmp-host-prohibited"]) + + def walu_block(self, mac): + subprocess.run(["iptables", "-D", "FORWARD", "-i", self.iface, + "-m", "mac", "--mac-source", mac, + "-j", "ACCEPT"]) + subprocess.run(["iptables", "-I", "FORWARD", "-i", self.iface, + "-m", "mac", "--mac-source", mac, + "-j", "REJECT", "--reject-with", "icmp-host-prohibited"]) + + def walu_unblock(self, mac): + subprocess.run(["iptables", "-D", "FORWARD", "-i", self.iface, + "-m", "mac", "--mac-source", mac, + "-j", "REJECT", "--reject-with", "icmp-host-prohibited"]) + subprocess.run(["iptables", "-I", "FORWARD", "-i", self.iface, + "-m", "mac", "--mac-source", mac, + "-j", "ACCEPT"]) + |