# Network Scan in Ansible

**URL:** <https://forum.ansible.com/t/network-scan-in-ansible/35227>\
**Category:** Ansible Project\
**Created:** [May 26, 2021, 2:22am UTC](https://forum.ansible.com/t/network-scan-in-ansible/35227 "2021-05-26T02:22:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dheeraj\_W](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@Dheeraj\_W](https://forum.ansible.com/u/Dheeraj_W)\
**Post date:** [May 26, 2021, 2:22am UTC](https://forum.ansible.com/t/network-scan-in-ansible/35227/1 "2021-05-26T02:22:59Z")

</div>

HI Guys , I have been assigned a task to find all the routers in the management range lets say [10.250.0.0/20](https://10.250.0.0/20) and script is expected to to start from first ip and run an interation til the last ip and ruunning show command like show version to fetch their version number and other vital parameters, so this task assumes all the routers are in this range, its just that we don’t know which ip is assigned to what? can I run a script to find all reachable routers in this range and ssh into them, fetch the info and save the output to a folder? I know it can easily be done in Python, however, I am not sure, if ansible gives that option without running those loops ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [May 26, 2021, 3:20pm UTC](https://forum.ansible.com/t/network-scan-in-ansible/35227/2 "2021-05-26T15:20:40Z")

</div>

See the nmap inventory plugin and snmp\_facts module as alternate ways  
to get most of this info.

The 'tree' callback plugin allows you to dump all results in a file  
'per host', this with the 'raw' or 'telnet' (if no ssh) actions might  
be of help.

---

<div class="post-metadata">

**Author:** ![Sumit\_Jaiswal](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@Sumit\_Jaiswal](https://forum.ansible.com/u/Sumit_Jaiswal)\
**Post date:** [June 3, 2021, 12:50pm UTC](https://forum.ansible.com/t/network-scan-in-ansible/35227/3 "2021-06-03T12:50:53Z")

</div>

Hi Dheeraj,

You can also checkout the Ansible.utils filter plugin _usable\_range_ (ref: [https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.usable\_range\_filter.rst#ansibleutilsusable\_range](https://github.com/ansible-collections/ansible.utils/blob/main/docs/ansible.utils.usable_range_filter.rst#ansibleutilsusable_range)).

**_Regards,_**  
Sumit Jaiswal (he/him)  
Github/IRC: _justjais_

---

<div class="post-metadata">

**Author:** ![Parth\_Patel](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@Parth\_Patel](https://forum.ansible.com/u/Parth_Patel)\
**Post date:** [June 3, 2021, 1:02pm UTC](https://forum.ansible.com/t/network-scan-in-ansible/35227/4 "2021-06-03T13:02:46Z")

</div>

If you intend not to use ansible.  
you can try using combination of nonir, pyATS CLI parsers to fetch required details from show version or any CLI commands.
