# Ansible.netcommon.net\_ping module – Tests reachability using ping from a network device

**URL:** <https://forum.ansible.com/t/ansible-netcommon-net-ping-module-tests-reachability-using-ping-from-a-network-device/44309>\
**Category:** Get Help\
**Tags:** cisco, ping, network\
**Created:** [August 17, 2025, 3:07am UTC](https://forum.ansible.com/t/ansible-netcommon-net-ping-module-tests-reachability-using-ping-from-a-network-device/44309 "2025-08-17T03:07:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![netmart](https://avatars.discourse-cdn.com/v4/letter/n/9e8a1a/32.png) [@netmart](https://forum.ansible.com/u/netmart)\
**Post date:** [August 17, 2025, 3:07am UTC](https://forum.ansible.com/t/ansible-netcommon-net-ping-module-tests-reachability-using-ping-from-a-network-device/44309/1 "2025-08-17T03:07:26Z")

</div>

```auto
Hello, 

I am trying to run a simple Ansible net_ping task, but for some reason it is not able to execute the command on switch:

It is probably something obvious I overlooked.

Though running the same command string in prompt mode directly on the switch, Cisco IOS XE, it is accepting it:

 
#ping ip 172.26.219.11 repeat 20 source 172.26.219.1
Type escape sequence to abort.
Sending 20, 100-byte ICMP Echos to 172.26.219.11, timeout is 2 seconds:
Packet sent with a source address of 172.26.219.1
!!!!!!!!!!!!!!!!!!!!

Ansible Runbook:

---

- name: Test network reachability

  hosts: iosxe  

  gather_facts: false

  tasks:

    - name: Ping the destination from the network device

      ansible.netcommon.net_ping:

       dest: 172.26.219.11

       source: 172.26.219.1

       count: 20

      register: ping_results

    - name: Display ping results

      debug:

        var: ping_results

 

debug:

run_commands

    return connection.run_commands(commands=commands, check_rc=check_rc)

  File "/usr/local/lib/python3.10/dist-packages/ansible/module_utils/connection.py", line 200, in __rpc__

    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)

fatal: [switch]: FAILED! => {

    "changed": false,

    "invocation": {

        "module_args": {

            "afi": "ip",

            "count": 20,

            "dest": "172.26.219.11",

            "df_bit": false,

            "egress": null,

            "ingress": null,

            "source": "172.26.219.1",

            "state": "present",

            "timeout": null,

            "vrf": null

        }

    },

    "msg": "ping ip 172.26.219.11 repeat 20 source 172.26.219.1\r\nTranslating \"ip\"...domain server (10.0.0.1)\r\n\r\nping ip 172.26.219.11 repeat 20 source 172.26.219.1\r\n ^\r\n% Invalid input detected at '^' marker.\r\n\r\nswitch>"

}

Thank you for your help.

Netmart

```
