Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cyber-sandbox-creator
Manage
Activity
Members
Labels
Plan
Issues
10
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MUNI-KYPO-CSC
cyber-sandbox-creator
Commits
610de7a6
Commit
610de7a6
authored
5 years ago
by
Attila Farkas
Browse files
Options
Downloads
Patches
Plain Diff
fix routing to Internet
parent
a097e8dc
No related branches found
No related tags found
2 merge requests
!6
Resolve "Convert BigBroker sandbox from KYPO-Creator to sandbox-creator"
,
!5
Resolve "Convert BigBroker sandbox from KYPO-Creator to sandbox-creator"
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
modules/file_generator.py
+2
-2
2 additions, 2 deletions
modules/file_generator.py
modules/network_parser.py
+4
-0
4 additions, 0 deletions
modules/network_parser.py
modules/routing.py
+1
-0
1 addition, 0 deletions
modules/routing.py
templates/br
+10
-1
10 additions, 1 deletion
templates/br
with
17 additions
and
3 deletions
modules/file_generator.py
+
2
−
2
View file @
610de7a6
...
...
@@ -3,7 +3,7 @@ import os
from
modules.device_creator
import
create_devices
from
modules.ansible_data_generator
import
create_network_map
,
create_host_map
,
create_network_ips
from
modules.routing
import
BORDER_ROUTER_IP
,
BORDER_ROUTER_NAME
,
BORDER_ROUTER_NETWORK_NAME
from
modules.routing
import
BORDER_ROUTER_IP
,
BORDER_ROUTER_NAME
,
BORDER_ROUTER_NETWORK_NAME
,
BORDER_ROUTER_PUBLIC_IP
def
_load_template
(
template_name
):
"""
Returns a loaded jinja2 template.
"""
...
...
@@ -185,7 +185,7 @@ def _generate_br_role(definitions):
routers_in_br_network
=
_get_br_routers
(
definitions
)
template
=
_load_template
(
"
br
"
)
output
=
template
.
render
(
hosts
=
host_map
,
routers
=
network
,
br_routes
=
routers_in_br_network
,
border_router_name
=
BORDER_ROUTER_NAME
)
output
=
template
.
render
(
hosts
=
host_map
,
routers
=
network
,
br_routes
=
routers_in_br_network
,
border_router_name
=
BORDER_ROUTER_NAME
,
border_router_public_ip
=
BORDER_ROUTER_PUBLIC_IP
)
_create_role_directory
(
"
br
"
)
_generate_file
(
"
./provisioning/roles/br/tasks/main.yml
"
,
output
)
...
...
This diff is collapsed.
Click to expand it.
modules/network_parser.py
+
4
−
0
View file @
610de7a6
"""
This module handles network creation.
"""
import
sys
from
modules.routing
import
BORDER_ROUTER_NAME
,
BORDER_ROUTER_PUBLIC_IP
def
_find_networks
(
hostname
,
mappings
,
device_type
):
...
...
@@ -50,6 +51,9 @@ def _add_interfaces(hostname, mapping, device_type, networks, definitions):
definitions
[
hostname
].
append
(
"
device.vm.network :private_network, ip:
\"
"
+
mapping
[
"
ip
"
]
+
"
\"
, virtualbox__intnet:
\"
"
+
mapping
[
"
network
"
]
+
"
\"
"
)
if
hostname
==
BORDER_ROUTER_NAME
:
definitions
[
BORDER_ROUTER_NAME
].
append
(
"
device.vm.network :public_network, ip:
\"
"
+
BORDER_ROUTER_PUBLIC_IP
+
"
\"
"
)
_add_netmask
(
hostname
,
mapping
[
"
network
"
],
networks
,
definitions
)
...
...
This diff is collapsed.
Click to expand it.
modules/routing.py
+
1
−
0
View file @
610de7a6
...
...
@@ -2,6 +2,7 @@ import sys
BORDER_ROUTER_NAME
=
"
br
"
BORDER_ROUTER_IP
=
"
172.18.0.1
"
BORDER_ROUTER_PUBLIC_IP
=
"
172.18.10.1
"
BORDER_ROUTER_NETWORK_NAME
=
"
BR
"
BORDER_ROUTER_NETWORK_IP
=
"
172.18.0.0/24
"
...
...
This diff is collapsed.
Click to expand it.
templates/br
+
10
−
1
View file @
610de7a6
...
...
@@ -27,5 +27,14 @@
{% for target_cidr, router_ip in br_routes.items() %}
- name: Add routing to network {{ target_cidr }}
command: route add -net {{ target_cidr }} gw {{ router_ip }} eth1
{% endfor %}
{% endfor %}
- name: Add postrouting
# ssh connection fails without async after execution of iptables commands
shell: "sleep 2 && sudo iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source {{ border_router_public_ip }}"
async: 1
poll: 0
- name: Save postrouting rule
command: su -c 'iptables-save > /etc/iptables.rules'
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment