Skip to content
Snippets Groups Projects
Commit c3f4f788 authored by NGUYEN Do Duc Anh's avatar NGUYEN Do Duc Anh
Browse files

fix bug dhcp service range

parent f248dcc1
No related branches found
No related tags found
No related merge requests found
......@@ -318,16 +318,16 @@ def stop_ids_solo5_hvt(process):
# print("----------------- No child process found to kill. -----------------")
def setup_dhcp(infs, ips, subnets):
def setup_dhcp(infs, ips, subnets, lower_bound_index, upper_bound_index):
dhcp_config = "default-lease-time 7200;\n" + \
"max-lease-time 7200;\n"
for i in range(len(subnets)):
subnet = subnets[i]
subnet_octets = subnet.split(".")
subnet_octets[-1] = "1"
subnet_octets[-1] = str(lower_bound_index)
lower_bound = ".".join(subnet_octets)
subnet_octets[-1] = "100"
subnet_octets[-1] = str(upper_bound_index)
upper_bound = ".".join(subnet_octets)
ip = ips[i]
dhcp_config += f"subnet {subnet} netmask 255.255.255.0 {{\n" + \
......@@ -473,7 +473,7 @@ def update_ospf_rule(input_map, total_router):
bgp_commands += f"\nneighbor 1.1.{i}.1 remote-as {MY_BGP_AS_NUM}"
bgp_commands += f"\nneighbor 1.1.{i}.1 update-source lo"
setup_dhcp(infs_user, ip_infs_user, subnets_user)
setup_dhcp(infs_user, ip_infs_user, subnets_user, 1, 1)
for subnet in subnets:
commands += f"\nnetwork {subnet}/24 area 0"
......
......@@ -205,7 +205,7 @@ def main():
if_utils.disable_NetworkManager_auto_ip("ens4")
if_utils.add_ip_address("ens4", f"10.0.{bgp_index}.254", "/24")
if_utils.setup_dhcp(["ens4"], [f"10.0.{bgp_index}.254"], [f"10.0.{bgp_index}.0"])
if_utils.setup_dhcp(["ens4"], [f"10.0.{bgp_index}.254"], [f"10.0.{bgp_index}.0"], 1, 100)
# Run thread to setup connection with uncontrolled AS - start at ens5
threading.Thread(target=setup_uncontrolled_AS, args=[5]).start()
......
......@@ -62,7 +62,7 @@ def update_ospf_rule(input_map, total_router):
bgp_commands += f"\nneighbor 3.3.{i}.3 remote-as {MY_BGP_AS_NUM}"
bgp_commands += f"\nneighbor 3.3.{i}.3 update-source lo"
if_utils.setup_dhcp(infs_user, ip_infs_user, subnets_user)
if_utils.setup_dhcp(infs_user, ip_infs_user, subnets_user, 1, 1)
for subnet in subnets:
commands += f"\nnetwork {subnet}/24 area 0"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment