def ips_in_net(ip='192.168.1.8', subnet='255.255.255.0'): from ipaddress import ip_address, ip_network hosts = list(ip_network(f"{ip}/{subnet}", strict=False).hosts()) return [f"{host}" for host in hosts]