{"id":6737,"library":"netutils","title":"netutils","description":"netutils is a Python library offering a collection of functions and objects for common network automation tasks, such as BGP ASN conversion, interface name standardization, MAC address formatting, IP address calculations, and configuration parsing. It is actively maintained with frequent releases, typically every few weeks, and is currently at version 1.17.2.","status":"active","version":"1.17.2","language":"en","source_language":"en","source_url":"https://github.com/networktocode/netutils","tags":["network","automation","parser","config","ip","mac","cisco","juniper"],"install":[{"cmd":"pip install netutils","lang":"bash","label":"Basic Install"},{"cmd":"pip install netutils[napalm]","lang":"bash","label":"Install with optional NAPALM dependencies"}],"dependencies":[{"reason":"Required for configuration parsing functionality, specifically for vendor-specific parsing rules.","package":"ntc-templates","optional":false},{"reason":"Optional dependency for functions that integrate with NAPALM (e.g., `get_napalm_getters`).","package":"napalm","optional":true}],"imports":[{"note":"Used for parsing device configurations based on provided text and OS type.","symbol":"ConfigParser","correct":"from netutils.config.parser import ConfigParser"},{"note":"For encrypting Cisco Type 7 passwords.","symbol":"encrypt_cisco_type7","correct":"from netutils.password import encrypt_cisco_type7"},{"note":"For standardizing network interface names across different platforms.","symbol":"normalize_interface_name","correct":"from netutils.interface import normalize_interface_name"}],"quickstart":{"code":"from netutils.config.parser import ConfigParser\n\n# Example Cisco IOS configuration string\nconfig_text = \"\"\"\nhostname my-router\ninterface GigabitEthernet0/0\n ip address 192.168.1.1 255.255.255.0\n no shutdown\ninterface Loopback0\n ip address 10.0.0.1 255.255.255.255\n\"\"\"\n\n# Instantiate the ConfigParser for Cisco IOS\n# 'cisco_ios' is a key from ntc-templates, which is a required dependency\ntry:\n    parser = ConfigParser(config_text, 'cisco_ios')\n    parsed_config = parser.parse()\n    print(\"Parsed Configuration:\\n\", parsed_config)\n\n    # Example using an IP utility function\n    from netutils.ip import is_valid_ipv4_address\n    print(f\"Is '192.168.1.1' a valid IPv4 address? {is_valid_ipv4_address('192.168.1.1')}\")\n\nexcept ImportError:\n    print(\"Error: 'ntc-templates' not found. Please install it: pip install ntc-templates\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to use `netutils.config.parser.ConfigParser` to parse a sample Cisco IOS configuration. It also includes a basic example of an IP utility function. Note that `ntc-templates` is a required dependency for the `ConfigParser` to function correctly."},"warnings":[{"fix":"Refactor code to subclass the appropriate private configuration parser class if extending HP Network OS parsing functionality. Consult the latest documentation for the correct base class.","message":"Direct instantiation of `HPEConfigParser` was deprecated in v1.17.0. Users should now subclass a private internal class instead.","severity":"breaking","affected_versions":">=1.17.0"},{"fix":"Upgrade to `netutils` version 1.15.2 or newer to ensure correct handling of `salt=0` in `encrypt_cisco_type7`.","message":"The `encrypt_cisco_type7` function in versions prior to 1.15.2 incorrectly ignored a `salt=0` parameter, leading to unexpected encryption results for that specific salt value.","severity":"gotcha","affected_versions":"<1.15.2"},{"fix":"Upgrade to `netutils` version 1.17.1 or newer to correctly parse empty Palo Alto Networks PanOS configurations.","message":"Parsing empty Palo Alto Networks PanOS configurations in versions prior to 1.17.1 would raise an error.","severity":"gotcha","affected_versions":"<1.17.1"},{"fix":"Ensure your Python environment is within the supported range (e.g., Python 3.10, 3.11, 3.12, 3.13, 3.14).","message":"The library explicitly requires Python versions >=3.10 and <3.15.","severity":"breaking","affected_versions":"All versions >=1.17.2"},{"fix":"Install `ntc-templates` explicitly: `pip install ntc-templates`.","message":"Many configuration parsing functionalities (e.g., `ConfigParser`) rely on the `ntc-templates` library. Failure to install `ntc-templates` will result in `ImportError` or `ConfigParser` not being able to find device OS definitions.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}