-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reserve IP addresses for supernodes (#4)
In order to create new supernodes on our own infrastructure, we first need to assign IP address prefixes and addresses for each supernode. --------- Co-authored-by: Mic Szillat <[email protected]>
- Loading branch information
Showing
11 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.vagrant/ | ||
|
||
.terraform/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Supernodes | ||
|
||
## IP Addressing | ||
|
||
- Assign a single IPv4 address per supernode | ||
- management IP to reach the machine | ||
- NAT IP to route client traffic | ||
- assigned from our `/24` aggregate | ||
- Assign a `/64` loopback prefix for all supernodes in a domain | ||
- each supernode gets one IP from this prefix |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
resource "null_resource" "test" { | ||
} | ||
|
||
module "supernode" { | ||
count = var.supernode_count | ||
|
||
source = "./modules/supernode" | ||
|
||
supernode_name = "${var.domain_name}_${count.index}" | ||
|
||
prefix_ipv4_id = data.netbox_prefix.primary_ipv4.id | ||
prefix_ipv6_id = netbox_available_prefix.domain_ipv6.id | ||
loopback_prefix_ipv6_id = netbox_prefix.loopback_ipv6.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
terraform { | ||
required_providers { | ||
netbox = { | ||
source = "e-breuninger/netbox" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
resource "netbox_available_prefix" "primary_ipv4" { | ||
description = "Primary Address ${var.supernode_name}" | ||
status = "active" | ||
|
||
parent_prefix_id = var.prefix_ipv4_id | ||
prefix_length = 32 | ||
|
||
tags = toset(var.tags) | ||
} | ||
|
||
resource "netbox_available_ip_address" "primary_ipv4" { | ||
status = "active" | ||
|
||
description = "Primary Address ${var.supernode_name}" | ||
|
||
prefix_id = netbox_available_prefix.primary_ipv4.id | ||
// TODO: set interface_id | ||
|
||
tags = toset(var.tags) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
resource "netbox_available_prefix" "primary_ipv6" { | ||
description = "Primary Address ${var.supernode_name}" | ||
status = "active" | ||
|
||
parent_prefix_id = var.loopback_prefix_ipv6_id | ||
prefix_length = 128 | ||
|
||
tags = toset(var.tags) | ||
} | ||
|
||
resource "netbox_available_ip_address" "primary_ipv6" { | ||
status = "active" | ||
|
||
description = "Primary Address ${var.supernode_name}" | ||
|
||
prefix_id = netbox_available_prefix.primary_ipv6.id | ||
// TODO: set interface_id | ||
|
||
tags = toset(var.tags) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
variable "supernode_name" { | ||
type = string | ||
description = "Name of the Supernode" | ||
} | ||
|
||
variable "tags" { | ||
type = list(string) | ||
description = "Tags for the resources" | ||
default = [] | ||
} | ||
|
||
variable "prefix_ipv4_id" { | ||
type = string | ||
description = "ID of the Supernode IPv4 prefix" | ||
} | ||
|
||
variable "prefix_ipv6_id" { | ||
type = string | ||
description = "ID of the Supernode IPv6 prefix" | ||
} | ||
|
||
variable "loopback_prefix_ipv6_id" { | ||
type = string | ||
description = "ID of the Loopback Supernode IPv6 prefix" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
data "netbox_prefix" "primary_ipv4" { | ||
prefix = var.primary_prefix_ipv4 | ||
} | ||
|
||
data "netbox_prefix" "primary_ipv6" { | ||
prefix = var.primary_prefix_ipv6 | ||
} | ||
|
||
resource "netbox_available_prefix" "domain_ipv6" { | ||
description = "Supernode IPv6 addresses ${var.domain_name}" | ||
prefix_length = 56 | ||
status = "reserved" | ||
parent_prefix_id = data.netbox_prefix.primary_ipv6.id | ||
|
||
tags = toset(var.tags) | ||
} | ||
|
||
resource "netbox_prefix" "loopback_ipv6" { | ||
prefix = cidrsubnet(netbox_available_prefix.domain_ipv6.prefix, 8, 0) | ||
description = "Supernode IPv6 loopback addresses ${var.domain_name}" | ||
status = "reserved" | ||
|
||
tags = toset(var.tags) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
terraform { | ||
required_providers { | ||
netbox = { | ||
source = "e-breuninger/netbox" | ||
version = "3.7.6" | ||
} | ||
} | ||
} | ||
|
||
provider "netbox" { | ||
server_url = "https://netbox.freifunk-duesseldorf.de" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
variable "domain_name" { | ||
type = string | ||
description = "Name of the supernode domain" | ||
default = "dev" | ||
} | ||
|
||
variable "tags" { | ||
type = list(string) | ||
description = "Tags for the resources" | ||
default = [] | ||
} | ||
|
||
variable "supernode_count" { | ||
type = number | ||
description = "Number of supernodes for this domain" | ||
default = 2 | ||
} | ||
|
||
variable "primary_prefix_ipv4" { | ||
type = string | ||
description = "Prefix to issue primary IPv4 addresses from" | ||
default = "45.151.166.0/24" | ||
} | ||
|
||
variable "primary_prefix_ipv6" { | ||
type = string | ||
description = "Prefix to issue primary IPv6 addresses from" | ||
default = "2001:678:b7c::/48" | ||
} |