As we all transition to ESXi there are certain activities that we need to figure out a new way of doing. One item that comes up in new deployments is making sure that all of the ESXi –> firewall rules are defined correctly.
I do not believe that there is a way to do this from the SDK so its off to Tech Support Mode. Unfortunately there is no telnet, netcat, or other network tool that I typically use.
Python to the rescue:
from socket import *
print "USAGE: %s <host> <port>" % (sys.argv,)
# Check the # of parameters
if not len(sys.argv) == 3:
# Check that the host and the port are appropriate.
host = sys.argv
port = int(sys.argv)
print "Attempting a TCP connection to host '%s' on port '%s'.\n" % (host, port)
s = socket(AF_INET, SOCK_STREAM)
except Exception, e:
print "Connection Failed: %s." % (e,)
print "Connection successful."
Python can also send UDP packets fairly easily, but since there is no connection the only way to tell if the traffic worked is to monitor it on in the network or on the destination side. As a result it is just as easy to do the operation that requires the port and if it fails, set up the traffic monitor.