{"id":369,"date":"2025-11-17T17:31:34","date_gmt":"2025-11-17T17:31:34","guid":{"rendered":"https:\/\/sites.wp.odu.edu\/isaac-huston\/?page_id=369"},"modified":"2025-11-17T17:33:12","modified_gmt":"2025-11-17T17:33:12","slug":"bash-ping-sweep-script","status":"publish","type":"page","link":"https:\/\/sites.wp.odu.edu\/isaac-huston\/skills\/scripting-and-automation\/bash-ping-sweep-script\/","title":{"rendered":"Bash Ping Sweep Script"},"content":{"rendered":"\n<p>Lightweight \/24 network discovery script that reduces noise before deeper scans. Built for repeatable reconnaissance.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\n# Function to extract network prefix from IP address\nget_network_prefix() {\n    local ip=\"$1\"\n    echo \"${ip%.*}\"\n}\n\n# Get the IP address of the host\nip_address=$(hostname -I | awk '{print $1}')\n\n# Check if an IP address is obtained\nif &#091; -z \"$ip_address\" ]; then\n    echo \"Failed to retrieve IP address. Please check your network connection.\"\n    exit 1\nfi\n\n# Extract the network prefix\nnetwork_prefix=$(get_network_prefix \"$ip_address\")\n\necho \"Network prefix: $network_prefix\"\n\n# Function to perform a ping sweep for a given IP\nping_sweep() {\n    local ip=\"$1\"\n    ping -c 1 -w 1 \"$ip\" &gt;\/dev\/null 2&gt;&amp;1 &amp;&amp; echo \"$ip\"\n}\n\n# Loop through 1 to 254 and ping each address\nfor ip in $(seq 1 254); do\n    ping_sweep \"$network_prefix.$ip\" &amp;\ndone\n\n# Wait for all background processes to complete\nwait\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Lightweight \/24 network discovery script that reduces noise before deeper scans. Built for repeatable reconnaissance.<\/p>\n","protected":false},"author":30346,"featured_media":0,"parent":326,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/sites.wp.odu.edu\/isaac-huston\/wp-json\/wp\/v2\/pages\/369"}],"collection":[{"href":"https:\/\/sites.wp.odu.edu\/isaac-huston\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sites.wp.odu.edu\/isaac-huston\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/isaac-huston\/wp-json\/wp\/v2\/users\/30346"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/isaac-huston\/wp-json\/wp\/v2\/comments?post=369"}],"version-history":[{"count":1,"href":"https:\/\/sites.wp.odu.edu\/isaac-huston\/wp-json\/wp\/v2\/pages\/369\/revisions"}],"predecessor-version":[{"id":370,"href":"https:\/\/sites.wp.odu.edu\/isaac-huston\/wp-json\/wp\/v2\/pages\/369\/revisions\/370"}],"up":[{"embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/isaac-huston\/wp-json\/wp\/v2\/pages\/326"}],"wp:attachment":[{"href":"https:\/\/sites.wp.odu.edu\/isaac-huston\/wp-json\/wp\/v2\/media?parent=369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}