Skip to content
Merged
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
32 changes: 16 additions & 16 deletions commands/init_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ def __init__(self, state_file: str = "../public/state.json"):
self.networks = {} # Maps network names to Docker networks
self.state = None
self.network_name = "llmguard_network"
self.base_ip = "172.20.0.0/16"
self.base_ip = "10.0.0.0/16"
self.connections = {} # Maps connection IDs to connection data
self.network_segments = {
'external': '172.20.1.0/24',
'dmz': '172.20.2.0/24',
'internal': '172.20.3.0/24',
'management': '172.20.4.0/24'
'external': '10.0.1.0/24',
'dmz': '10.0.2.0/24',
'internal': '10.0.3.0/24',
'management': '10.0.4.0/24'
}
self.ip_assignments = {} # Maps node IDs to assigned IPs

Expand Down Expand Up @@ -151,7 +151,7 @@ def create_custom_network(self) -> Network:
pool_configs=[
docker.types.IPAMPool(
subnet=self.base_ip,
gateway="172.20.0.1"
gateway="10.0.0.1"
)
]
),
Expand Down Expand Up @@ -186,29 +186,29 @@ def assign_ip_address(self, node_id: str, node_index: int) -> str:
segment = self.network_segments['external']
base_ip = int(segment.split('.')[2])
ip_host = 10 + node_index
ip = f"172.20.{base_ip}.{ip_host}"
ip = f"10.0.{base_ip}.{ip_host}"
elif node_type == 'firewall':
# Firewall gets IP in management segment and acts as gateway
ip = "172.20.0.2" # Main gateway
ip = "10.0.0.2" # Main gateway
elif node_type == 'router':
# Router gets IP in management segment
ip = "172.20.0.3"
ip = "10.0.0.3"
elif node_type == 'server':
# Servers in DMZ
segment = self.network_segments['dmz']
base_ip = int(segment.split('.')[2])
ip_host = 10 + (node_index % 240)
ip = f"172.20.{base_ip}.{ip_host}"
ip = f"10.0.{base_ip}.{ip_host}"
elif node_type in ['user', 'switch']:
# Users and switches in internal network
segment = self.network_segments['internal']
base_ip = int(segment.split('.')[2])
ip_host = 10 + (node_index % 240)
ip = f"172.20.{base_ip}.{ip_host}"
ip = f"10.0.{base_ip}.{ip_host}"
else:
# Default assignment
ip_host = 10 + node_index
ip = f"172.20.0.{ip_host}"
ip = f"10.0.0.{ip_host}"

self.ip_assignments[node_id] = ip
return ip
Expand Down Expand Up @@ -366,7 +366,7 @@ def configure_host_rules(self, container: Container, node_data: Dict[str, Any])
f"iptables -A INPUT -s {firewall_ip} -j ACCEPT",
"ip route del default",
f"ip route add default via {router_ip}",
f"ip route replace 172.20.3.0/24 via {router_ip}"
f"ip route replace 10.0.3.0/24 via {router_ip}"
]

for cmd in setup_commands:
Expand All @@ -390,9 +390,9 @@ def configure_router_rules(self, container: Container, node_data: Dict[str, Any]
"iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT",
"iptables -A INPUT -p icmp -j ACCEPT",
"iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT",
"iptables -A FORWARD -s 172.20.3.0/24 -d 172.20.3.0/24 -p icmp -j ACCEPT",
"iptables -A FORWARD -s 172.20.3.0/24 -d 172.20.3.0/24 -j ACCEPT",
f"ip route replace 172.20.3.0/24 via {firewall_ip}"
"iptables -A FORWARD -s 10.0.3.0/24 -d 10.0.3.0/24 -p icmp -j ACCEPT",
"iptables -A FORWARD -s 10.0.3.0/24 -d 10.0.3.0/24 -j ACCEPT",
f"ip route replace 10.0.3.0/24 via {firewall_ip}"
]

for cmd in setup_commands:
Expand Down
Loading