Skip to content

paintedman00/check-ports

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Port Checker Script

A simple bash script to check if specific ports are open on a host.

Overview

This script checks the status of specified ports on a host (defaulting to localhost) to determine if they are open or closed. It uses the nc (netcat) command to perform the checks.

Usage

  1. Download the Script:

    Save the script to a file, e.g., check_ports.sh.

  2. Make the Script Executable:

    chmod +x check_ports.sh
  3. Run the Script:

    ./check_ports.sh

Script Details

Function check_port

This function checks if a specific port is open on a specified host.

  • Parameters:

    • $1: The port number to check.
    • $2 (optional): The host to check (defaults to localhost).
  • Example:

    check_port 80
    check_port 80 example.com

Port List

The script includes a predefined list of ports to check:

ports=(80 443 22 53)

You can modify this list to include any ports you want to check.

Example Output

Port 80 is open on localhost!
Port 443 is open on localhost!
Port 22 is open on localhost!
Port 53 is open on localhost!

Customizing the Script

  • Change Ports:

    Edit the ports array to include the ports you want to check:

    ports=(80 443 22 53 8080)
  • Change Host:

    To check ports on a different host, modify the script to pass the host as a second argument:

    ./check_ports.sh example.com

Dependencies

  • nc (netcat): Ensure nc is installed on your system. You can install it using your package manager, for example:

    • On Debian/Ubuntu:

      sudo apt-get install netcat
    • On CentOS/RHEL:

      sudo yum install nc
    • On macOS:

      brew install netcat

ns or suggestions!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages