To open a port and configure it for TCP connections on a Linux system, follow these steps:
Begin by selecting a port to open; for this tutorial, we’ll use port 4000. If this port is already in use, feel free to select another closed port. Ensure that the chosen port is greater than 1023.
To confirm that port 4000 is not in use, employ the netstat command:
netstat -na | grep :4000
To ensure the port is available for manual configuration with iptables, confirm that the output of the previous command remains empty, indicating that the port is not in use.
If you’re using Ubuntu or a ufw-based system, you can utilize ufw, the command-line client for the Uncomplicated Firewall. Below are the commands you’ll need to enter:
sudo ufw allow 4000