Is port open automatically on linux?

agusmrc

New Member
Credits
25
I have an application to deliver the traffic from Server-A to Server-B.
On Server-A : delivers traffic though from port 10000 till port 19000 randomly
On Server-B (Centos 7)
- receives the traffic from port 10000 till port 19000
- no firewall installed and no restriction on a specific port on this server

During the test, I need to capture the traffic on Server-B using tcpdump : tcpdump -i eth1 portrange 10000-19999 -s0 -w /tmp/pcap-test.pcap

In order to test the traffic delivery from Server-A to Server-B :
- Should I open the port (from port 10000 till port 19000) on Server-B? Or the port will open automatically since no firewall on Server-B?
If yes, how to open multiple ports using range on Centos 7?
- Should I use Socat command to open the port?


Thanks
 


wh47n0w

New Member
Credits
19
Server-A will not need any firewall modifications. Outbound connections are allowed.

Server-B will not need firewall modifications, since there is no firewall. It will need an application to listen and accept connections on that socket. The server will refuse traffic on that port, if nothing is listening. I'm not a developer and haven't personally used Socat so cannot comment there. Netcat is a potential option.
 
  • Like
Reactions: Rob

agusmrc

New Member
Credits
25
I used Socat and Netcat to listen on those port (10000 till port 19000 ) using loop.
Unfortunately, the server was suddenly hung after opening so many ports

The Netcat script as follows :
first_port=10000
last_port=19000

for (( i = first_port+1; i <= last_port; i++ )) do
ncat -l -k -p $i -c "nc localhost $last_port" &
done

ncat -l -k -p $first_port



The Socat script as follows :
for i in {10000..19000}
do
socat -u TCP4-LISTEN:$i,reuseaddr,fork OPEN:/tmp/test-$i,creat,append
done


Is there another way? Opening so many ports without freeze the server
 


Members online


Top