This Bash script performs a TCP connection test to a specified IP address and port using various utilities such as netcat
, telnet
, and nmap
. It also checks for required dependencies and logs the results to files for later analysis.
- Target IP:
192.168.1.10
- Target Port:
44818
- Log Files:
YYYY-MM-DD_HH:MM:SS-tcp_connection_test.log
(General log)YYYY-MM-DD_HH:MM:SS-tcp_connection_test_error.log
(Error log)
The script checks for the following dependencies:
nc
(netcat)telnet
nmap
If any of these dependencies are missing, the script attempts to install them using apt
.
- Make sure you have
bash
installed. - Ensure you have
sudo
privileges if dependencies need to be installed. - Execute the script using
./tcp_connection_test.sh
.
- General Log: Contains all script execution details, including successful connections and any errors encountered.
- Error Log: Captures errors encountered during dependency checks, installation attempts, and connection tests.
After execution, the script provides:
- Connection status (success or failure) for
netcat
,telnet
, andnmap
tests. - Detailed logs for each test and overall script execution.
- Timestamped log files for easy tracking and debugging.
If the script fails:
- Check the error logs (
YYYY-MM-DD_HH:MM:SS-tcp_connection_test_error.log
) for specific error messages. - Verify network connectivity and target device availability.
- Ensure dependencies are installed correctly and accessible.