Skip to content

Commit

Permalink
Add dynamic docker subnet detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Ecnama committed Nov 14, 2024
1 parent 6ad0f1c commit b32941a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion netcontrol/nft.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def setup_portail(self):

# Block other traffic from users that are not authenticated
self._execute_nft_cmd("add chain insalan netcontrol-forward { type filter hook forward priority 0; }")
self._execute_nft_cmd(f"add rule insalan netcontrol-forward ip daddr != {{ 172.16.1.1,172.30.0.0/16 }} ip saddr {variables.ip_range()} ip saddr != {{ 172.16.1.1,172.30.0.0/16 }} ether saddr != @netcontrol-auth reject")
docker_subnet = ".".join(docker0_ip.split(".")[:1]) + ".0.0/16"
self._execute_nft_cmd(f"add rule insalan netcontrol-forward ip daddr != {{ 172.16.1.1,{docker_subnet} }} ip saddr {variables.ip_range()} ip saddr != {{ 172.16.1.1,{docker_subnet} }} ether saddr != @netcontrol-auth reject")

self.logger.info("Gate nftables set up")

Expand Down

0 comments on commit b32941a

Please sign in to comment.