The Free Encyclopedia

Server Testing Guide

Revision as of Jun 25, 2026 23:19 by migration. This is an old revision โ€” view current.

๐Ÿ“‹ Table of Contents

Overview

This guide covers essential techniques for testing your own servers using two powerful command-line tools:

Tools Covered

๐Ÿ”ง netcat (nc)
                    Swiss army knife for network connections - excellent for basic connectivity tests and data transfer
๐Ÿš€ hping3
                    Advanced packet crafting and network testing tool for sophisticated testing scenarios

โš ๏ธ Important Safety Notice

Always test only servers you own or have explicit permission to test. Unauthorized testing may violate terms of service or local laws.

Prerequisites

  • Root or sudo access on your test machine
  • Basic understanding of TCP/IP networking
  • Target servers that you own and have permission to test

Installation

Ubuntu/Debian

Copy
                    sudo apt-get update
sudo apt-get install netcat-openbsd hping3

CentOS/RHEL/Fedora

Copy
                    sudo yum install nc hping3
# or for newer versions:
sudo dnf install nc hping3

macOS

Copy
                    # netcat is pre-installed
brew install hping

Netcat (nc) Testing

Basic Port Connectivity Testing

Test if a port is open
                    
                        Copy
                        # Basic TCP connection test
nc -zv server_ip port
nc -zv 192.168.1.100 80

# Test multiple ports
nc -zv 192.168.1.100 80-90

# UDP port test
nc -zuv 192.168.1.100 53
Test port ranges
                    
                        Copy
                        # Scan ports 1-1000
nc -zv server_ip 1-1000

# Common service ports
nc -zv server_ip 21,22,23,25,53,80,110,143,443,993,995

Service Banner Grabbing

HTTP service testing
                    
                        Copy
                        # Connect to HTTP server
nc server_ip 80
# Then type: GET / HTTP/1.1 followed by two newlines

# Automated HTTP test
echo -e "GET / HTTP/1.1\r\nHost: server_ip\r\n\r\n" | nc server_ip 80
SSH banner grab
                    
                        Copy
                        nc server_ip 22
# Server will respond with SSH version banner

File Transfer Testing

Simple file server
                    
                        Copy
                        # On receiving server
nc -l -p 8080 > received_file.txt

# On sending machine
nc server_ip 8080 < file_to_send.txt

hping3 Advanced Testing

Basic Connectivity Tests

ICMP ping alternative
                    
                        Copy
                        # Standard hping3 ping
hping3 -c 4 server_ip

# TCP ping to specific port
hping3 -S -p 80 -c 4 server_ip

# UDP ping
hping3 -2 -p 53 -c 4 server_ip

Firewall and Filter Testing

Test firewall rules
                    
                        Copy
                        # Test if TCP port is filtered
hping3 -S -p 443 -c 3 server_ip

# Test different TCP flags
hping3 -F -p 80 -c 3 server_ip  # FIN flag
hping3 -A -p 80 -c 3 server_ip  # ACK flag
hping3 -P -p 80 -c 3 server_ip  # PUSH flag

Load Testing

๐Ÿ”” Controlled Testing

Be extremely careful with flood tests. Start with low rates and monitor your server's response.

Connection rate testing
                    
                        Copy
                        # Controlled rate SYN test
hping3 -S -p 80 -i u1000 server_ip  # 1000 microsecond interval

# Test connection establishment rate
hping3 -S -p 80 -i u100 -c 1000 server_ip

Comprehensive Testing Scenarios

Web Server Testing

Copy
                    # 1. Basic connectivity
nc -zv web_server 80 443

# 2. HTTP response test
echo -e "GET / HTTP/1.1\r\nHost: web_server\r\n\r\n" | nc web_server 80

# 3. SSL/TLS port test
nc -zv web_server 443

# 4. Load response test
hping3 -S -p 80 -i u1000 -c 100 web_server

Database Server Testing

Copy
                    # MySQL/MariaDB
nc -zv db_server 3306

# PostgreSQL
nc -zv db_server 5432

# Redis
nc -zv db_server 6379
echo "PING" | nc db_server 6379

# MongoDB
nc -zv db_server 27017

SSH Server Testing

Copy
                    # Basic connectivity
nc -zv ssh_server 22

# Banner grab
nc ssh_server 22

# Test SSH with different algorithms
hping3 -S -p 22 -c 3 ssh_server

Performance Benchmarking

Bandwidth Testing

Simple bandwidth test using nc
                    
                        Copy
                        # Server side:
nc -l -p 8080 | pv > /dev/null

# Client side:
dd if=/dev/zero bs=1M count=1000 | pv | nc server_ip 8080

Latency Testing

Copy
                    # Round-trip time measurement
hping3 -c 100 -i u10000 server_ip | grep round-trip

# TCP connection time
hping3 -S -p 80 -c 10 server_ip | grep round-trip

Troubleshooting Common Issues

Connection Timeouts

Copy
                    # Increase timeout
nc -w 10 server_ip port

# Test with different protocols
hping3 -1 server_ip  # ICMP
hping3 -2 -p 53 server_ip  # UDP
hping3 -S -p 80 server_ip  # TCP SYN

Firewall Detection

Copy
                    # Test for stateful firewall
hping3 -A -p 80 server_ip  # Should be dropped if stateful

# Test for port filtering
hping3 -S -p 12345 server_ip  # Test non-standard port

Best Practices

๐Ÿ›ก๏ธ Safety Guidelines

  • Always test only servers you own or have explicit permission to test
  • Start with gentle tests before aggressive ones
  • Monitor server resources during testing
  • Have rollback plans for any configuration changes
  • Document baseline performance before testing

Testing Methodology

1. Baseline establishment: Record normal server behavior

2. Incremental testing: Start with simple tests, increase complexity

3. Documentation: Keep detailed logs of all tests and results

4. Validation: Verify server functionality after each test phase

5. Cleanup: Remove any test files or temporary configurations

๐Ÿ’ก Pro Tips

  • Don't test production servers during peak hours
  • Avoid overwhelming servers with excessive connections
  • Be cautious with flood tests - they can cause legitimate DoS
  • Always check legal compliance for your testing activities
  • Don't leave nc listeners running indefinitely