{"id":2663,"date":"2022-02-13T22:21:00","date_gmt":"2022-02-13T22:21:00","guid":{"rendered":"https:\/\/www.balajibandi.com\/?p=2663"},"modified":"2025-08-31T07:27:24","modified_gmt":"2025-08-31T06:27:24","slug":"asa-duplicate-ip-in-object-groups","status":"publish","type":"post","link":"https:\/\/www.balajibandi.com\/?p=2663","title":{"rendered":"ASA duplicate IP in Object-Groups"},"content":{"rendered":"\n<p>I have various ASA model in the network and various engineer work to create different ACL . Object and Groups, this become over head of too many Objects and Object-group with Duplicate IP.<\/p>\n\n\n\n<p>So i have used below Python script to extract the information from config.<\/p>\n\n\n\n<p>show run (download the ASA config on Linux host and run below Python file) <\/p>\n\n\n\n<p><strong>find_duplicate_ips.py<\/strong> (below content)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import re\nfrom collections import defaultdict\n\n# Replace with your ASA config file path\nwith open('asa_config.txt') as f:\n    asa_config = f.read()\n\n# Find all object-group network blocks\nog_pattern = re.compile(r'(object-group network .+?)(?=object-group|\\Z)', re.DOTALL)\nip_pattern = re.compile(r'network-object host (&#91;\\d.]+)')\n\nip_to_groups = defaultdict(list)\n\nfor block in og_pattern.findall(asa_config):\n    # Extract group name\n    group_match = re.search(r'object-group network (\\S+)', block)\n    if not group_match:\n        continue\n    group_name = group_match.group(1)\n    # Find IP entries\n    for ip in ip_pattern.findall(block):\n        ip_to_groups&#91;ip].append(group_name)\n\n# Report duplicate IPs used in multiple object-groups\nfor ip, groups in ip_to_groups.items():\n    if len(groups) > 1:\n        print(f'Duplicate IP {ip} is in object-groups: {groups}')\n\n\n<strong>python3 -m pdb find_duplicate_ips.py<\/strong>\n\nHappy Labbbbingggggggggggggggggggggg!<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I have various ASA model in the network and various engineer work to create different ACL . Object and Groups, this become over head of too many Objects and Object-group with Duplicate IP. So i have used below Python script to extract the information from config. show run (download the ASA config on Linux host [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,2],"tags":[],"class_list":["post-2663","post","type-post","status-publish","format-standard","hentry","category-ccie-sec","category-cisco"],"_links":{"self":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts\/2663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2663"}],"version-history":[{"count":2,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts\/2663\/revisions"}],"predecessor-version":[{"id":2665,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts\/2663\/revisions\/2665"}],"wp:attachment":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}