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

admin and user network #25

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
roles/
venv/
.venv/
.env
.terragrunt-cache/
.terraform.lock.hcl
Expand Down
8 changes: 8 additions & 0 deletions ansible/deploy/firewall/firewall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,24 @@
type: ipv4,
interface: { name: $DMZIF, broadcast: detect, options: "routeback,bridge,nosmurfs" }
}
- {
name: admin,
type: ipv4,
interface: { name: $ADMINIF, broadcast: detect, options: "routeback,bridge,nosmurfs" }
}
policy:
- { source: fw, dest: all, policy: ACCEPT }
- { source: lan, dest: inet, policy: ACCEPT }
- { source: dmz, dest: inet, policy: ACCEPT }
- { source: admin, dest: all, policy: ACCEPT }
- THIS POLICY HAS TO BE THE LAST
- { source: all, dest: all, policy: REJECT, log: info }
rules:
# - { action: DNAT, source: inet, dest: "lan:192.168.213.10:22", proto: tcp, dest_port: 10022 }
- Permit access to SSH
- { action: SSH/ACCEPT, source: lan, dest: fw }
- { action: SSH/ACCEPT, source: dmz, dest: fw }
- { action: SSH/ACCEPT, source: admin, dest: fw }
# - { action: ACCEPT, source: inet, dest: fw, proto: tcp, dest_port: "443,8006" }
- PING Rules
- { action: Ping/ACCEPT, source: all, dest: all }
Expand All @@ -51,5 +58,6 @@
- { name: INETIF, value: ens3 }
- { name: LANIF, value: ens4 }
- { name: DMZIF, value: ens5 }
- { name: ADMINIF, value: ens6 }

- role: auditd
3 changes: 2 additions & 1 deletion ansible/run/scenario1/templates/scenario_1_c_a.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ vars:
$SERVER_ADDRESS: 192.42.0.254
$ATTACKER_ADDRESS: 192.42.1.174
$DNS_SERVER: 192.42.0.233
$ADMIN_SERVER: 10.12.0.222
$DOMAIN: aecid-testbed.com
$USER: aecid
$DNS_LIST: /usr/local/share/SecLists/Discovery/DNS/subdomains-top1million-5000.txt
Expand Down Expand Up @@ -131,7 +132,7 @@ commands:

- type: ssh
cmd: echo "ssh -i .ssh/rootkey -o StrictHostKeyChecking=no [email protected] reboot" | at now + 2 minute
hostname: 192.168.100.222
hostname: $ADMIN_SERVER
username: aecid
password: aecid
jmp_hostname: 192.42.2.42
Expand Down
2 changes: 1 addition & 1 deletion ansible/run/scenario1/templates/scenario_1_c_b.j2
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ commands:

- type: ssh
cmd: echo "ssh -i .ssh/rootkey -o StrictHostKeyChecking=no [email protected] reboot" | at now + 2 minute
hostname: 192.168.100.222
hostname: $ADMIN_SERVER
username: aecid
password: aecid
jmp_hostname: "192.42.2.42"
Expand Down
2 changes: 1 addition & 1 deletion ansible/run/scenario1/templates/scenario_1_c_c.j2
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ commands:

- type: ssh
cmd: echo "ssh -i .ssh/rootkey -o StrictHostKeyChecking=no [email protected] reboot" | at now + 2 minute
hostname: 192.168.100.222
hostname: $ADMIN_SERVER
username: aecid
password: aecid
jmp_hostname: "192.42.2.42"
Expand Down
3 changes: 2 additions & 1 deletion ansible/run/scenario1/templates/scenario_1_d_a.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ vars:
$SERVER_ADDRESS: 192.42.0.254
$ATTACKER_ADDRESS: 192.42.1.174
$DNS_SERVER: 192.42.0.233
$ADMIN_SERVER: 10.12.0.222
$DOMAIN: aecid-testbed.com
$USER: aecid
$DNS_LIST: /usr/local/share/SecLists/Discovery/DNS/subdomains-top1million-5000.txt
Expand Down Expand Up @@ -132,7 +133,7 @@ commands:

- type: ssh
cmd: echo "ssh -i .ssh/rootkey -o StrictHostKeyChecking=no [email protected] '. /etc/bash_completion'" | at now + 10 minute
hostname: 192.168.100.222
hostname: $ADMIN_SERVER
username: aecid
password: aecid
jmp_hostname: 192.42.2.42
Expand Down
3 changes: 2 additions & 1 deletion ansible/run/scenario1/templates/scenario_1_d_b.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ vars:
$SERVER_ADDRESS: 192.42.0.254
$ATTACKER_ADDRESS: 192.42.1.174
$DNS_SERVER: 192.42.0.233
$ADMIN_SERVER: 10.12.0.222
$DOMAIN: aecid-testbed.com
$USER: aecid
$DNS_LIST: /usr/local/share/SecLists/Discovery/DNS/subdomains-top1million-5000.txt
Expand Down Expand Up @@ -132,7 +133,7 @@ commands:

- type: ssh
cmd: echo "ssh -i .ssh/rootkey -o StrictHostKeyChecking=no [email protected] '. /etc/bash_completion'" | at now + 10 minute
hostname: 192.168.100.222
hostname: $ADMIN_SERVER
username: aecid
password: aecid
jmp_hostname: 192.42.2.42
Expand Down
2 changes: 1 addition & 1 deletion ansible/run/scenario1/templates/scenario_1_d_c.j2
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ commands:

- type: ssh
cmd: echo "ssh -i .ssh/rootkey -o StrictHostKeyChecking=no [email protected] '. /etc/bash_completion'" | at now + 10 minute
hostname: 192.168.100.222
hostname: $ADMIN_SERVER
username: aecid
password: aecid
jmp_hostname: 192.42.1.232
Expand Down
3 changes: 2 additions & 1 deletion ansible/run/scenario3/templates/scenario_3_c.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ vars:
$SERVER_ADDRESS: 192.42.0.254
$ATTACKER_ADDRESS: 192.42.1.174
$DNS_SERVER: 192.42.0.233
$ADMIN_SERVER: 10.12.0.222

commands:
- type: shell
Expand Down Expand Up @@ -202,7 +203,7 @@ commands:

- type: ssh
cmd: echo "ssh -i .ssh/rootkey -o StrictHostKeyChecking=no [email protected] \"apt update && apt install -y healthcheckd\"" | at now + 2 minute
hostname: 192.168.100.223
hostname: $ADMIN_SERVER
username: aecid
password: aecid
jmp_hostname: 192.42.2.42
Expand Down
9 changes: 9 additions & 0 deletions packer/firewall/playbook/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@
type: ipv4,
interface: { name: $DMZIF, broadcast: detect, options: "routeback,bridge,nosmurfs" }
}
- {
name: admin,
type: ipv4,
interface: { name: $ADMINIF, broadcast: detect, options: "routeback,bridge,nosmurfs" }
}
policy:
- { source: fw, dest: all, policy: ACCEPT }
- { source: admin, dest: all, policy: ACCEPT }
- { source: lan, dest: inet, policy: ACCEPT }
- { source: lan, dest: dmz, policy: ACCEPT }
- { source: dmz, dest: inet, policy: ACCEPT }
Expand All @@ -64,9 +70,11 @@
- Permit access to SSH
- { action: SSH/ACCEPT, source: lan, dest: fw }
- { action: SSH/ACCEPT, source: dmz, dest: fw }
- { action: SSH/ACCEPT, source: admin, dest: fw }
- Permit access to DNS
- { action: DNS/ACCEPT, source: lan, dest: fw }
- { action: DNS/ACCEPT, source: dmz, dest: fw }
- { action: DNS/ACCEPT, source: admin, dest: fw }
# - { action: ACCEPT, source: inet, dest: fw, proto: tcp, dest_port: "443,8006" }
- PING Rules
- { action: Ping/ACCEPT, source: all, dest: all }
Expand All @@ -78,6 +86,7 @@
- { name: INETIF, value: ens3 }
- { name: LANIF, value: ens4 }
- { name: DMZIF, value: ens5 }
- { name: ADMINIF, value: ens6 }
- { name: REPOSERVER, value: 172.17.100.122}
- { name: LINUXSHARE, value: 192.168.100.23}
- { name: VIDEOSERVER, value: 172.17.100.121}
Expand Down
92 changes: 67 additions & 25 deletions terragrunt/bootstrap/module/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resource "openstack_networking_network_v2" "internet" {
resource "openstack_networking_subnet_v2" "internet_subnet" {
name = "internet_subnet"
network_id = "${openstack_networking_network_v2.internet.id}"
cidr = var.inet_cidr
cidr = var.subnet_cidrs["inet"]
dns_nameservers = var.inet_dns
ip_version = 4
}
Expand Down Expand Up @@ -70,7 +70,7 @@ resource "openstack_compute_instance_v2" "inet-dns" {

network {
name = "internet"
fixed_ip_v4 = cidrhost(var.inet_cidr,514)
fixed_ip_v4 = cidrhost(var.subnet_cidrs["inet"],514)
}

depends_on = [
Expand All @@ -92,15 +92,15 @@ resource "openstack_networking_network_v2" "lan" {
resource "openstack_networking_subnet_v2" "lan_subnet" {
name = "lan_subnet"
network_id = "${openstack_networking_network_v2.lan.id}"
cidr = var.lan_cidr
cidr = var.subnet_cidrs["lan"]
ip_version = 4
gateway_ip = cidrhost(var.lan_cidr,254)
dns_nameservers = [cidrhost(var.lan_cidr,254)]
gateway_ip = cidrhost(var.subnet_cidrs["lan"],254)
dns_nameservers = [cidrhost(var.subnet_cidrs["lan"],254)]

# make the allocation_pool smaller for gateway_ip
allocation_pool {
start = cidrhost(var.lan_cidr,20)
end = cidrhost(var.lan_cidr,200)
start = cidrhost(var.subnet_cidrs["lan"],20)
end = cidrhost(var.subnet_cidrs["lan"],200)
}
}

Expand All @@ -117,19 +117,46 @@ resource "openstack_networking_network_v2" "dmz" {
resource "openstack_networking_subnet_v2" "dmz_subnet" {
name = "dmz_subnet"
network_id = "${openstack_networking_network_v2.dmz.id}"
cidr = var.dmz_cidr
cidr = var.subnet_cidrs["dmz"]
ip_version = 4
gateway_ip = cidrhost(var.dmz_cidr,254)
dns_nameservers = [cidrhost(var.dmz_cidr,254)]
gateway_ip = cidrhost(var.subnet_cidrs["dmz"],254)
dns_nameservers = [cidrhost(var.subnet_cidrs["dmz"],254)]


# make the allocation_pool smaller for gateway_ip
allocation_pool {
start = cidrhost(var.dmz_cidr,20)
end = cidrhost(var.dmz_cidr,200)
start = cidrhost(var.subnet_cidrs["dmz"],20)
end = cidrhost(var.subnet_cidrs["dmz"],200)
}
}

###################################################################
#
# CREATE NETWORK "ADMIN"
#
resource "openstack_networking_network_v2" "admin" {
name = "admin"
port_security_enabled = "false"
admin_state_up = "true"
}

resource "openstack_networking_subnet_v2" "admin_subnet" {
name = "admin_subnet"
network_id = "${openstack_networking_network_v2.admin.id}"
cidr = var.subnet_cidrs["admin"]
ip_version = 4
gateway_ip = cidrhost(var.subnet_cidrs["admin"],254)
dns_nameservers = [cidrhost(var.subnet_cidrs["admin"],254)]


# make the allocation_pool smaller for gateway_ip
allocation_pool {
start = cidrhost(var.subnet_cidrs["admin"],20)
end = cidrhost(var.subnet_cidrs["admin"],200)
}
}


####################################################################
#
# CREATE INSTANCE for "Internet-Firewall"
Expand Down Expand Up @@ -167,24 +194,30 @@ resource "openstack_compute_instance_v2" "inet-fw" {

network {
name = "internet"
fixed_ip_v4 = cidrhost(var.inet_cidr,254)
fixed_ip_v4 = cidrhost(var.subnet_cidrs["inet"],254)
}

network {
name = "lan"
fixed_ip_v4 = cidrhost(var.lan_cidr,254)
fixed_ip_v4 = cidrhost(var.subnet_cidrs["lan"],254)
}

network {
name = "dmz"
fixed_ip_v4 = cidrhost(var.dmz_cidr,254)
fixed_ip_v4 = cidrhost(var.subnet_cidrs["dmz"],254)
}

network {
name = "admin"
fixed_ip_v4 = cidrhost(var.subnet_cidrs["admin"],254)
}

depends_on = [
openstack_compute_instance_v2.inet-dns,
openstack_networking_network_v2.dmz,
openstack_networking_network_v2.internet,
openstack_networking_network_v2.lan
openstack_networking_network_v2.lan,
openstack_networking_network_v2.admin
]
}

Expand Down Expand Up @@ -215,9 +248,12 @@ data "openstack_images_image_v2" "mgmt-image" {
}

locals {
mgmt_internet_ip = cidrhost(var.inet_cidr, 201) # Static IP for mgmt host in internet network
mgmt_lan_ip = cidrhost(var.lan_cidr, 201) # Static IP for mgmt host in lan network
mgmt_dmz_ip = cidrhost(var.dmz_cidr, 201) # Static IP for mgmt host in dmz network
mgmt_ips = {
internet = cidrhost(var.subnet_cidrs["inet"], 201)
lan = cidrhost(var.subnet_cidrs["lan"], 201)
dmz = cidrhost(var.subnet_cidrs["dmz"], 201)
admin = cidrhost(var.subnet_cidrs["admin"], 201)
}
}

resource "openstack_compute_instance_v2" "mgmt" {
Expand All @@ -229,29 +265,35 @@ resource "openstack_compute_instance_v2" "mgmt" {

network {
name = "internet"
fixed_ip_v4 = local.mgmt_internet_ip
fixed_ip_v4 = local.mgmt_ips.internet
}

network {
name = "lan"
fixed_ip_v4 = local.mgmt_lan_ip
fixed_ip_v4 = local.mgmt_ips.lan
}

network {
name = "dmz"
fixed_ip_v4 = local.mgmt_dmz_ip
fixed_ip_v4 = local.mgmt_ips.dmz
}

network {
name = "admin"
fixed_ip_v4 = local.mgmt_ips.admin
}

depends_on = [
openstack_networking_network_v2.dmz,
openstack_networking_network_v2.internet,
openstack_networking_network_v2.lan
]
openstack_networking_network_v2.lan,
openstack_networking_network_v2.admin,

]
}

data "openstack_networking_port_v2" "mgmt"{
fixed_ip = local.mgmt_internet_ip
fixed_ip = local.mgmt_ips.internet
depends_on = [
openstack_compute_instance_v2.mgmt
]
Expand Down
25 changes: 9 additions & 16 deletions terragrunt/bootstrap/module/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ variable "ext_router" {
description = "name of the external router"
}

variable "inet_cidr" {
type = string
description = "CIDR of the internet subnet"
default = "192.42.0.0/16"
}

variable "inetdns_flavor" {
type = string
description = "flavor of the internet dns server"
Expand Down Expand Up @@ -76,14 +70,13 @@ variable "inet_dns" {
default = ["1.1.1.1","8.8.8.8"]
}

variable "lan_cidr" {
type = string
description = "CIDR of the lan subnet"
default = "192.168.100.0/24"
}

variable "dmz_cidr" {
type = string
description = "CIDR of the dmz subnet"
default = "172.17.100.0/24"
variable "subnet_cidrs" {
type = map(string)
description = "CIDRs for various subnets"
default = {
inet = "192.42.0.0/16"
lan = "192.168.100.0/24"
dmz = "172.17.100.0/24"
admin = "10.12.100.0/24"
}
}
Loading