A quick app to test network egress from a CF space.
This app is intended for testing application security group rules in Cloud Foundry. Once deployed to CF, it provides a quick check of network egress from the running application (e.g. from within a CF space). It provides a UI form for testing connectivity to a specific host:port, and an HTTP endpoint at GET /egress-status/tcp|udp/{host}/{port}
.
- Clone this repo.
- Ruby is required. Ruby installation info
- Install the Ruby bundler for dependency management using
gem install bundler
- Download dependencies with
bundle install
. - Run the app with
bundle exec rackup
or justrackup
. - The app should be reachable at http://localhost:9292/.
Assuming you have a local CF instance on bosh-lite:
- Deploy the app with
cf push egress-test
. - Navigate to the app's route, fill out the form for
google.com:80
, verify connectivity. - Remove outbound access to public networks.
cf unbind-running-security-group public_networks
cf restart egress-test
- From the app, again fill out the form for
google.com:80
, this time verifying that the connection is refused.
To restore connectivity for a specific destination, such as google.com, add a security group opening only that egress.
nslookup google.com
- Take one of the resolved IP addresses (e.g.
216.58.216.78
, though there are many) and enter it into a security group definition such as
cat << EOF > asg_google-public-http.json
[
{
"protocol": "tcp",
"destination": "216.58.216.78",
"ports": "80"
}
]
EOF
- Apply the security group
> cf create-security-group google asg_google-public-http.json
> cf bind-security-group google me development
> cf restart egress-test
- Navigate to the app again and verify connectivity to that IP (e.g.
216.58.216.78:80
).