summaryrefslogtreecommitdiff
path: root/src/walu/wall.py
blob: 18c45949d87525cb008622c34e8c834971c87637 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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"])