Skip to main content

Posts

Showing posts from May, 2022

How to check for open TCP ports in Linux using netcat, ssh, nmap, telnet and even just cat

    There are may ways to check for open TCP ports. Usually I prefer to use netcat or telnet, however in some cases (especially within docker containers) these tools are not installed or available. This post shows most common ways to check if a remote port is open or not. telnet Even though the telnet client tool is supposed to be used for the telnet protocol (ie. remotely logging in to a Unix computer before we had ssh), it is also a handy tool to check for an open port. For example, we can use it to check if we can access www.google.com via HTTPS: $ telnet www.google.com 443 Trying 142.250.70.196... Connected to www.google.com. If we see the " Connected " message, we can deduct from this that the port is open - even though there are protocol differences. Furthermore, if the service is unencrypted, telnet will show us status messages / protocol hints and versions etc. The following connects to a Google mail / SMTP server. $ telnet smtp.google.com 25 Trying 74.125.24.27... Co

Viewing and tailing multiple Kubernetes container logs concurrently

Why Often I need to look at multiple pod logs at the same time. For example the nginx ingress controller deployment or daemonset usually has at least a handful of pods running to share the load and for additional redundancy. To troubleshoot problems, I need to see them all. Options The trusted kubectl (I am a kube cuttle guy) command has an option to view or tail multiple containers based on a selector like this. $ kubectl logs -n nginx-ingress -l ' app.kubernetes.io/name=fluent -bit '  -f  --max-log-requests 60 --tail=1 --prefix=true However, if the pods in question come and go frequently, I am recommending stern instead:   https://github.com/wercker/stern