Giter VIP home page Giter VIP logo

testnc's Introduction

testnc: A simple program to test network connectivity via TCP

Getting started

  1. Download and unpack the asset for your platform from the release page.

  2. Open a terminal and run the program.

# Linux
al@linux ~ $ ./testnc github.com:443
 OK :: 10.0.1.10 -> github.com:443 -> 140.82.121.4:443

al@linux ~ $ ./testnc github.com:8080
BAD :: github.com:8080 -> 140.82.121.4:8080
# Windows
PS C:\Users\al> .\testnc.exe --help
A simple program to test TCP network connectivity

Usage: testnc.exe [OPTIONS] [CONNECTIONS]...

Arguments:
  [CONNECTIONS]...  One or more connection strings in the form 'host:port'

Options:
  -t, --timeout <TIMEOUT>  Timeout for each connection in seconds [default: 1]
  -f, --file <FILE>        File with connection strings in the form 'host:port' separated by newlines
  -h, --help               Print help (see more with '--help')
  -V, --version            Print version

Testing multiple connections

To test multiple connections, use command-line arguments:

al@linux ~ $ ./testnc github.com:443 github.com:22
 OK :: 10.0.1.10 -> github.com:443 -> 140.82.121.3:443
 OK :: 10.0.1.10 -> github.com:22 -> 140.82.121.3:22

Or use a text file with a list of connections:

al@linux ~ $ cat ./connections.txt
github.com:22
github.com:443
github.com:8080

al@linux ~ $ ./testnc --file connections.txt
 OK :: 10.0.1.10 -> github.com:22 -> 140.82.121.4:22
 OK :: 10.0.1.10 -> github.com:443 -> 140.82.121.4:443
BAD :: github.com:8080 -> 140.82.121.4:8080

Pass multiple files like this:

al@linux ~ $ ./testnc --file connections.txt --file more-connections.txt

You can annotate your connection list with # comment lines:

al@linux ~ $ cat ./connections.txt
# Github
github.com:22
github.com:443
# This should fail:
github.com:8080

al@linux ~ $ ./testnc --file connections.txt
# Github
 OK :: 10.0.1.10 -> github.com:22 -> 140.82.121.3:22
 OK :: 10.0.1.10 -> github.com:443 -> 140.82.121.3:443
# This should fail:
BAD :: github.com:8080 -> 140.82.121.3:8080

Testing connections on multiple hosts

You can let Ansible run this program on different hosts and collect the results.

Copy the program to a location where Ansible can find it, e.g. next to a playbook.

- name: Example play
  hosts: all
  tasks:
    - name: testnc - copy, run and then remove binary
      ansible.builtin.script: testnc {{ connections | join(" ") }}
      changed_when: false  # the script module always reports 'changed' on return code zero.
      register: testnc_result
      vars:
        connections:
          - github.com:22
          - github.com:443
          - github.com:8080

    - name: testnc - print results
      ansible.builtin.debug:
        var: testnc_result.stdout_lines

License

Copyright © 2023 Andreas Longo

GNU General Public License v3.0 or later

testnc's People

Contributors

andreaslongo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.