open port 8080 for listening

You are confusing two concepts. Iptables handles access control for your networking. When you accept input traffic with a destination of TCP port 8008 that you just means you are letting the internet send traffic to that port. It has no effect on what, if anything, is listening on the port.

To listen on a port you need a program set up to do that. In your original case, tomcat was that program. You stopped it so now nothing is listening on that port. To open it back up as a listener you need to start tomcat, or any other program that you want, to listen on that port. What program you select to listen on that port is entirely dependent on what service you want to provide on that port.

The iptables commands don't affect whether or not your program is listening, it just affects whether or not traffic from the internet is allowed to talk to that program.

If you just want to open up a network port that dumps whatever is sent to it, the program you want is netcat. The command

nc -l -p 8080 

This will cause netcat to listen on port 8080 and dump whatever is sent to that port to standard output. You can redirect its output to a file if you want to save the data sent to that port. If you want anything more sophisticated than a raw data dump, you will need to determine what specific program(s) are capable of handling your data and start one of those instead.


You do not open a port. You run a program, and the program listens for connections on a port. So you need to ensure that no other programs are listening to port 8080, then you need to configure your program to listen to port 8080, and then you need to run your program.

Tags:

Linux

Tcp