bundles/dhcpd: add iptables rules

This commit is contained in:
Franzi 2020-11-15 12:01:14 +01:00
parent cdef8cdb13
commit ad569f073e
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -23,6 +23,7 @@ def get_static_allocations(metadata):
}
}
@metadata_reactor
def get_listen_interfaces(metadata):
listen_interfaces = []
@ -34,3 +35,19 @@ def get_listen_interfaces(metadata):
'listen_interfaces': ' '.join(sorted(listen_interfaces)),
}
}
@metadata_reactor
def iptables(metadata):
iptables = set()
for identfier, subnet in node.metadata.get('dhcpd/subnets', {}).items():
iptables.add('iptables -A INPUT -i {} -p udp --dport 67:68 -j ACCEPT'.format(subnet.get('interface')))
return {
'iptables': {
'bundle_rules': {
# iptables bundle relies on this being a list.
'dhcpd': sorted(list(iptables)),
},
}
}