Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

output reserved IP for subnets #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

output reserved IP for subnets #98

wants to merge 1 commit into from

Conversation

ronakbanka
Copy link
Contributor

@ronakbanka ronakbanka commented Feb 13, 2019

WHY?
With use of terraforming-aws for infrastructure paving, one important part which is missing from terraform output file is reserved IPs for each subnet. If reserved IPs are not in network config, BOSH will try to pick the very first IP and fail as it is reserved.

As per AWS VPC documentation, First 4 IPs are reserved in each subnet.

The first four IP addresses and the last IP address in each subnet CIDR block are not available for you to use, and cannot be assigned to an instance. For example, in a subnet with CIDR block 10.0.0.0/24, the following five IP addresses are reserved:

10.0.0.0: Network address.

10.0.0.1: Reserved by AWS for the VPC router.

10.0.0.2: Reserved by AWS. The IP address of the DNS server is always the base of the VPC network range plus two; however, we also reserve the base of each subnet range plus two. For VPCs with multiple CIDR blocks, the IP address of the DNS server is located in the primary CIDR. For more information, see Amazon DNS Server.

10.0.0.3: Reserved by AWS for future use.

10.0.0.255: Network broadcast address. We do not support broadcast in a VPC, therefore we reserve this address.

CHANGES

  • Get reserved ip range by using cidrhost function for subnets.

Output will look something like this:

infrastructure_subnet_cidrs = [
    10.0.16.0/28,
    10.0.16.16/28,
    10.0.16.32/28
]
infrastructure_subnet_reserved_ips = [
    10.0.16.0-10.0.16.3,
    10.0.16.16-10.0.16.19,
    10.0.16.32-10.0.16.35
]

Similarly for other subnets.

How this was used?
This was used to automate opsmanager deployment by fetching properties like

      "name": "infrastructure",
      "service_network": false,
      "subnets": [
        {
          "iaas_identifier": ((infrastructure_subnet_ids_az1)),
          "cidr": ((infrastructure_subnet_cidrs_az1)),
          "dns": "8.8.8.8",
          "gateway": ((infrastructure_subnet_gateways_az1)),
          "reserved_ip_ranges": ((infrastructure_subnet_reserved_ips_z1)),
          "availability_zone_names": [((az1))]
        }
      ]

reference: config link

@ronakbanka
Copy link
Contributor Author

Any update on this??

@nwmahoney
Copy link
Contributor

Hey @ronakbanka. Sorry for the lack of communication here. We have been focusing on a different product recently and haven't had the bandwidth to stay on top of PRs to our various repos. We will try to get to it soon, but it may be a little while longer. Let me know if this is blocking you and I'll try to merge it ASAP.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants