- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Discovering all Devices in a subnet using ESXCLI
I'd like to run a ping command using ESXCLI that does the following:
Utilizes a specific vmkernel port to run on so I can test the functionality using that vmkernel port.
Pings every host in a given subnet to determine what IPs are online in that subnet.
How can I do this with ESXCLI?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is possible to ping using a specific interface with ESXCLI, but not sure how you would loop this through every IP address.
~ # esxcli network diag ping --help
Usage: esxcli network diag ping [cmd options]
Description:
ping Send ICMP echo requests to network hosts.
Cmd options:
-c|--count=<long> Specify the number of packets to send.
-D|--debug VMKPing debug mode.
-d|--df Set DF bit on IPv4 packets.
-H|--host=<str> Specify the host to send packets to. (required)
-I|--interface=<str> Specify the outgoing interface.
-i|--interval=<str> Set the interval for sending packets in seconds.
-4|--ipv4 Ping with ICMPv4 echo requests.
-6|--ipv6 Ping with ICMPv6 echo requests.
--netstack=<str> Specify the TCP/IP netstack which the interface resides on
-N|--nexthop=<str> Override the system's default route selection, in dotted quad notation. (IPv4 only. Requires interface option)
-s|--size=<long> Set the payload size of the packets to send.
-t|--ttl=<long> Set IPv4 Time To Live or IPv6 Hop Limit
-W|--wait=<str> Set the timeout to wait if no responses are received in seconds.
~ #
Why don't you write a PowerShell script to do this as you will have a lot more flexibility, and can still use ESXCLI with the Get-Exscli cmdlet.
Cheers,
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Pings every host in a given subnet to determine what IPs are online in that subnet.
I would doubt that logic would work, since the ips which reply can also be a gateway, dns, or other workstations, neways, you could come with a simple script like
for i in `seq 255`; do for j in `seq 255`; do echo 192.168.$i.$j; esxcli network diag ping -H 192.168.$i.$j -I vmk0 -c 1 | grep -i Recieved | awk '{if($2 == 1) {print "Alive"} else print "Dead"}'; done; done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok thanks. PowerCLI won't work in this case as I need to use this on new hosts that haven't been joined to vcenter server yet and are in a new subnet. Also, is there anyway to write that script to a file, and then download the file to my pc, given that I can't connect yet with putty but only through the esxi shell since the networking is still not configured yet when I'm doing this research?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you mean you want the output to a file, then
for i in `seq 255`; do for j in `seq 255`; do echo 192.168.$i.$j; esxcli network diag ping -H 192.168.$i.$j -I vmk0 -c 1 | grep -i Recieved | awk '{if($2 == 1) {print "Alive"} else print "Dead"}' >> Discovery.txt; done; done