diff --git a/core/libs/commonwealth/commonwealth/utils/DHCPServerManager.py b/core/libs/commonwealth/commonwealth/utils/DHCPServerManager.py index 1fa2cf4f9a..79aebb54b0 100644 --- a/core/libs/commonwealth/commonwealth/utils/DHCPServerManager.py +++ b/core/libs/commonwealth/commonwealth/utils/DHCPServerManager.py @@ -3,7 +3,7 @@ import subprocess import time from ipaddress import IPv4Address, IPv4Interface, IPv4Network -from typing import Any, List, Optional, Union +from typing import Any, List, Optional, Tuple, Union import psutil from loguru import logger @@ -16,7 +16,7 @@ def __init__( interface: str, ipv4_gateway: IPv4Address, subnet_mask: Optional[IPv4Address] = None, - ipv4_lease_range: Optional[tuple[IPv4Address, IPv4Address]] = None, + lease_range: Tuple[int, int] = (101, 200), lease_time: str = "24h", ) -> None: self._subprocess: Optional[Any] = None @@ -32,9 +32,15 @@ def __init__( subnet_mask = IPv4Address("255.255.255.0") self._subnet_mask = subnet_mask - if ipv4_lease_range is None: - # If no lease-range is defined we offer all available IPs for lease - ipv4_lease_range = (list(self.ipv4_network.hosts())[100], list(self.ipv4_network.hosts())[199]) + if 0 < lease_range[0] < 256 and 0 < lease_range[1] < 256 and lease_range[0] < lease_range[1]: + ipv4_lease_range = ( + list(self.ipv4_network.hosts())[lease_range[0] - 1], + list(self.ipv4_network.hosts())[lease_range[1] - 1], + ) + else: + logger.error(f"Outside valid lease range: {lease_range}") + ipv4_lease_range = (list(self.ipv4_network.hosts())[0], list(self.ipv4_network.hosts())[-1]) + self._ipv4_lease_range = ipv4_lease_range self._lease_time = lease_time diff --git a/core/services/cable_guy/main.py b/core/services/cable_guy/main.py index 6ae6db3670..f85486b3e2 100755 --- a/core/services/cable_guy/main.py +++ b/core/services/cable_guy/main.py @@ -40,7 +40,7 @@ if args.default_config == "bluerov2": default_configs = [ - NetworkInterface(name="eth0", addresses=[InterfaceAddress(ip="192.168.2.2", mode=AddressMode.Unmanaged)]), + NetworkInterface(name="eth0", addresses=[InterfaceAddress(ip="192.168.2.2", mode=AddressMode.Server)]), NetworkInterface(name="usb0", addresses=[InterfaceAddress(ip="192.168.3.1", mode=AddressMode.Server)]), ]