Manually opening TCP ports

Siraj Shaikh siraj.shaikh at
Sun Mar 9 11:07:15 UTC 2008

On 09/03/2008, Michael R. Head <burner at> wrote:
> On Fri, 2008-03-07 at 08:02 +0000, Siraj Shaikh wrote:
> > Hello
> >
> > I am just wondering if there is a utility (or any feature in
> > ubuntu/Linux) that allows me to manually open a TCP port on a machine.
> > I am looking for a way that could either allow me to open ALL or many
> > TCP ports on a machine.
> >
> > Also, is there any way of running a service on more than a single
> > port, or on all or many ports?
> After reading the rest of the thread, it appears to me that the best
> solution would be to forward the ports you want to listen on to your
> application. This can be done with iptables. For example, if you want to
> forward all ports from 1 to 1024 to your server (which might be running
> at 31337), then you could do it thusly:
> for (( PORT=1; PORT<=1024; PORT++ )); do
>  sudo iptables -t nat -A PREROUTING -p tcp --dport $PORT  -j DNAT --to
> done

Thanks. We might actually forward all ports to a service we run. This
would mean doing it for 65534 ports and the one port left can be used
to run the service. So any probe received on any of the ports would be
picked up by our service.

What is the best tool (in linux) for us to log all packets that arrive
at a particular port? Which simply receives any packets and stores the
entire contents in a file, or logs it on syslog or some mysql


More information about the ubuntu-users mailing list