IPCalcReturnSubnetAddresses
An automation script to return subnet addresses.
python · Community Common Scripts
Source
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 from CommonServerUserPython import * import ipaddress import traceback """ COMMAND FUNCTION """ def return_subnet_addresses_command(args: Dict[str, Any]) -> CommandResults: subnet = args.get("subnet", None) address_objects = ipaddress.IPv4Network(subnet, strict=False).hosts() addresses = [] for address_object in address_objects: addresses.append(format(address_object)) readable_output = tableToMarkdown(headers="IP Addresses:", t=addresses, name="List Addresses") return CommandResults( outputs_prefix="IPCalc.IP.Address", outputs_key_field="", readable_output=readable_output, outputs=addresses, ) """ MAIN FUNCTION """ def main(): try: return_results(return_subnet_addresses_command(demisto.args())) except Exception as ex: demisto.error(traceback.format_exc()) return_error(f"Failed to execute IPCalcReturnSubnetAddresses. Error: {str(ex)}") """ ENTRY POINT """ if __name__ in ("__main__", "__builtin__", "builtins"): main()
README
An automation script to return subnet addresses
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | |
| Cortex XSOAR Version | 6.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| subnet | Subnet to use |
Outputs
| Path | Description | Type |
|---|---|---|
| IPCalc.IP.Address | Subnet addresses | String |
Script Example
!IPCalcReturnSubnetAddresses subnet=192.168.20.90/28
Context Example
{
"IPCalc": {
"IP": {
"Address": [
"192.168.20.81",
"192.168.20.82",
"192.168.20.83",
"192.168.20.84",
"192.168.20.85",
"192.168.20.86",
"192.168.20.87",
"192.168.20.88",
"192.168.20.89",
"192.168.20.90",
"192.168.20.91",
"192.168.20.92",
"192.168.20.93",
"192.168.20.94"
]
}
}
}
Human Readable Output
List Addresses
IP Addresses: 192.168.20.81 192.168.20.82 192.168.20.83 192.168.20.84 192.168.20.85 192.168.20.86 192.168.20.87 192.168.20.88 192.168.20.89 192.168.20.90 192.168.20.91 192.168.20.92 192.168.20.93 192.168.20.94