Probe
net_probe_internet¶
Test basic internet connectivity by attempting a TCP connection to a well-known host via bash's /dev/tcp device.
Arguments¶
- $1 (string): Optional: host to test (default: 8.8.8.8)
- $2 (int): Optional: port to test (default: 53)
Exit codes¶
- 0: Connection succeeded
- 1: Connection failed or timed out
net_probe_port¶
Test connectivity to a remote host's port via bash /dev/tcp or /dev/udp. Requires bash with /dev/tcp support. For environments where that is unavailable (e.g. minimal containers) use net_probe_tcp instead.
Example¶
net_probe_port example.com 443
net_probe_port example.com 53 udp
Arguments¶
- $1 (string): Remote hostname or IP address
- $2 (int): Port number (default: 22)
- $3 (string): Protocol: tcp or udp (default: tcp)
Exit codes¶
- 0: Port is reachable
- 1: Port is unreachable or timed out
net_probe_wait¶
Poll a host/port until it becomes reachable or a timeout expires. Retries once per second using net_probe_port.
Example¶
net_probe_wait db.example.com 5432 60
Arguments¶
- $1 (string): Remote hostname or IP address
- $2 (int): Port number (default: 22)
- $3 (int): Timeout in seconds (default: 30)
Exit codes¶
- 0: Port became reachable within the timeout
- 1: Timeout expired before port was reachable
net_probe_tcp¶
Test TCP connectivity to a host and port using curl's telnet:// scheme. Works in minimal container environments that lack bash /dev/tcp, nslookup, telnet, and nc. Reliable for server-speaks-first protocols (e.g. MySQL, Redis, SQL Server) where curl exit code 28 is ambiguous — inspects verbose output for "Connected to" to confirm the TCP handshake succeeded, then kills curl immediately. Completely silent; callers are responsible for all messaging.
Example¶
net_probe_tcp db.internal 5432 && printf '%s\n' "reachable"
net_probe_tcp 10.0.0.1 6379 10
Arguments¶
- $1 (string): Hostname or IP address
- $2 (int): TCP port number
- $3 (int): Optional: connect timeout in seconds (default: 5)
Exit codes¶
- 0: TCP connection established
- 1: Connection failed (refused, timed out, or DNS failure)