Manually opening TCP ports
Michael R. Head
burner at suppressingfire.org
Sun Mar 9 09:01:04 UTC 2008
On Fri, 2008-03-07 at 08:02 +0000, Siraj Shaikh wrote:
> 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 127.0.0.1:31337
Michael R. Head <burner at suppressingfire.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3259 bytes
Desc: not available
More information about the ubuntu-users