Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mbus firewall rules #353

Closed
Tracked by #892
ramonskie opened this issue May 27, 2024 · 2 comments
Closed
Tracked by #892

mbus firewall rules #353

ramonskie opened this issue May 27, 2024 · 2 comments
Labels

Comments

@ramonskie
Copy link
Contributor

currently the agent uses iptables to create mbus firewall rules.
as we now use cgroupv2 these rules wont work anymore.

we could add this now to the stemcell. or the agent
if we put it in the stemcell it would look something like the script below
and we could use systemd to run this when the bosh agent is ready.
as the rules won't be added if the cgroup does not exists which is done once the agent is started.
and it should also be renewed if the agent restarts.

#!/bin/bash

mbusurl=$(cat settings.json | jq -r .mbus)
mbushost=$(echo ${mbusurl#*//} | cut -d':' -f1)
mbusport=${mbusurl##*:}

if [ -z "$mbusurl" ]; then
  echo "No mbus url found in settings.json"
  exit 1
else
    if [[ $mbusurl =~ https://* ]]; then
        echo "mbus url contains https and no rules are needed"
        exit 0
    fi
fi

echo "my nats ip $mbushost and por $mbusport"

nft add chain inet filter nats_postrouting '{ type filter hook postrouting priority 0 ; policy accept ; }'
nft add rule inet filter nats_output socket cgroupv2 level 2 "system.slice/bosh-agent.service" ip daddr $mbushost tcp dport $mbusport log prefix "\"Matched cgroup bosh-agent nats rule: \"" accept
nft add rule inet filter nats_output skuid 0 ip daddr $mbushost tcp dport $mbusport log prefix "\"Matched skuid director nats rule: \"" accept
nft add rule inet filter nats_output ip daddr $mbushost tcp dport $mbusport log prefix "\"dropped nats rule: \"" drop
@ramonskie
Copy link
Contributor Author

this pr should fix this issue
cloudfoundry/bosh-agent#332

@ramonskie
Copy link
Contributor Author

we now skip firewall creation due the fact that we are now using temp credentials.
fixxed in https://github.com/cloudfoundry/bosh-agent/pull/332/files

@github-project-automation github-project-automation bot moved this from Waiting for Changes | Open for Contribution to Done in Foundational Infrastructure Working Group Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

1 participant