Here is a quick tutorial on simulating TCP and UDP clients on any Linux OS of your choice.
#1 - Using Pseudo Devices
Suppose a TCP/UDP server is running in a local/remote machine and you want to check whether it actually receives the messages originated from your terminal machine, but you don’t have a client to do this. Then, you can use this method straight away to send an instant TCP/UDP packet to the desired destination over a desired port.
// Base Command
$ echo "YOUR_MESSAGE" > /dev/{TRANSPORT_PROTOCOL}/{DESTINATION_IP}/{DESTINATION_PORT}
// TCP
$ echo "This is my TCP message" > /dev/tcp/127.0.0.1/30100
// UDP
$ echo "This is my UDP message" > /dev/udp/127.0.0.1/30000
#2 - Using NetCat (NCat)
If you need your TCP/UDP client to keep the TCP/UDP connection open (just like a chat client), use the below
NetCat command. It will give you an open connection, so that you can input messages line by line. Each time you
click Enter/Return
button, to go to the next line, NetCat will send the currently -typed message to the given
server.
// TCP
nc localhost 31000
> Hello world from TCP client!
// UDP
$ nc -u localhost 30000
> Hello world from UDP client!
If you need to install NetCat or find out more options, read here
✅ Tested OS's | : RHEL 7+, CentOS 7+, Ubuntu 18.04+, Debian 8+ |
---|---|
✅ Tested Gear | : Cloud (AWS EC2), On-Prem (Bare Metal) |
Leave a comment