|
From: | Hans Schou |
Subject: | Re: Testing firewall ports with parallel |
Date: | Fri, 19 Jan 2018 00:19:59 +0100 |
Hi all,
Like a lot of GNU software parallel is awesome.
Need help, am trying to test if servers we manage have the required
firewall ports open. Have tried a few things but am not winning so far.
This works, but is quite terrible and inefficient. Sure it could be
simpler and better.
How can I achieve the below equivalent in a better way?
NOTE: I only want to test particular ports for a specific host. Hence I
used an associated array in bash.
#!/usr/bin/env bash
declare -A dst_hosts
dst_hosts=(
[cloud-ec.amp.cisco.com]='443 32137'
[console.amp.cisco.com]='443'
[mgmt.amp.cisco.com]='443'
[intake.amp.cisco.com]='443'
[policy.amp.cisco.com]='443'
[crash.amp.cisco.com]='443'
[ioc-schema.amp.cisco.com]='443'
[api.amp.cisco.com]='443'
[sourcefire-apps.s3.amazonaws.com ]='443'
[update.immunet.com]='80 443'
[defs.amp.sourcefire.com]='80 443'
[cloud-ec-asn.amp.sourcefire.com ]='443'
[cloud-ec-est.amp.sourcefire.com ]='443'
[android.amp.sourcefire.com]='443'
[cloud-pc.amp.sourcefire.com]='443 32137'
[packages.amp.sourcefire.com]='443'
[support-sessions.amp.sourcefire.com ]='443'
[cloud-dc.amp.sourcefire.com]='443 32137'
[export.amp.sourcefire.com]='443'
[intel.api.sourcefire.com]='443'
)
for dst_host in "${!dst_hosts[@]}"; do
parallel -P 0 nc -w 2 -vz ${dst_host} ::: ${dst_hosts[$dst_host]} ;
done
Also, ideally I could use parallel to do the above test in parallel on
multiple hosts.
--
Divan
[Prev in Thread] | Current Thread | [Next in Thread] |