Urgent.News

What's breaking now, across thousands of outlets.

Tech

Consider Using the nc Command for Connectivity Verification

Introduction When verifying connectivity to external servers or databases, which command do you typically use? I'd like to recommend the nc (Netcat) command for this purpose. Why I Recommend the nc Command The nc (Netcat) command is convenient for connectivity verification. Here's how to use it: $ nc -zv < hostname or IP address> <port number> $ nc -zv google.com 80 If you see Connection to ...…

When trying to establish a connection to external servers or databases, many people turn to the nc (Netcat) command for verification. This utility is particularly useful in this scenario due to its simplicity and effectiveness. To use it, you would enter the following command: `$ nc -zv hostname or IP address port number`. If the connection is successful, the output "Connection to ... succeeded!" is displayed.

For example, if you were trying to connect to google.com on port 80, the command would be `$ nc -zv google.com 80`. Upon successful connection, you would see the message "Connection to google.com (142.250.207.46) 80 port [tcp/http] succeeded!" This indicates that the connectivity is functioning correctly.

Although one might initially consider using ping for connectivity checks, it's important to note that ping utilizes the ICMP protocol. If the receiving end does not permit ICMP, the test will fail, which can happen due to security groups or firewalls blocking it. Instead of relying solely on ping, it's recommended to verify the ability to access the API or database at the network level using the nc command.

This approach ensures that any issues at the underlying network level are identified early on, making troubleshooting more efficient.

While curl or psql can be used to test application layer connectivity after confirming network level access, it's still prudent to use the nc command first. This provides a layer-by-layer verification process, helping to pinpoint the source of any connection failures.

Telnet, a traditional method for establishing connections, is often discouraged due to security concerns. For these reasons, the nc command stands out as a practical and underrated tool for connectivity verification. It provides clear indications about open TCP ports and even supports UDP, making it a versatile option. However, keep in mind that nc might not be pre-installed on all systems, such as Amazon Linux.

In such cases, you would need to install it using the package manager, for instance, with the command `$ dnf install nmap-ncat`.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Android AppFunctions Is in Beta. The Code Is Still Alpha

The Android Developers account called AppFunctions "officially in beta" from the Android Dev Summit stage. The Jetpack library it points you to is 1.0.0-alpha10 . That gap is the whole story.

  • Android AppFunctions in beta, code still alpha
  • Developers declare functions with @AppFunction annotation
  • API requires Android 16+, inaccessible to most users

More from Sunday 1 November →