Firstly, We should know that what is netcat, which is also known as TCP/IP swiss army knife a feature-rich network utility. netcat can do port scanning, transfer files, create a listener, or stream media, and many more. The netcat utility program supports a wide range of commands to manage networks and monitor the flow of traffic data between systems.
Install netcat in Linux:
sudo apt-get install netcat
Compile Netcat From Source:
1. Download Netcat from an official source
2. To decompress it run the following command,
Here, “netcat-0.7.1.tar.gz” is the name of the file.
3. untar the file.
tar -xf netcat-0.7.1.tar
4. Change the directory.
cd netcat-0.7.1 /
5. by using the command configure the source code.
6. Compile the program by using.
7. Now install it.
Creating a Simple Chat
We will follow these steps for configuring a chat.
Steps 1: To create a simple chat you need two devices, d1 and d2.
Step 2: Open a terminal in Linux and install Netcat on both devices.
Step 3: type $ifconfig in d1 and note down your localhost IP address, ifconfig is used to get our device’s IP address.
Step 4: Now in d1 run command $nc -nvlp 1234 where “1234” is port number, d1 will now act as a listener.
- -n: nodns, Do not resolve hostname vis DNS
- -v: verbose, set verbosity level
- -l: listener, binds and listen for incoming connection
- -p: source-port port, Specify source port to use
Step 5: in d2 type $nc <localhost IP> 1234 and hit enter.
Step 6: Simple chat is now created.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.