Manually opening TCP ports

Dan Nelson dnelson at
Fri Mar 7 15:32:58 UTC 2008

In the last episode (Mar 07), Siraj Shaikh said:
> I am just wondering if there is a utility (or any feature in FreeBSD)
> 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?

If you are concerned about managing 65000 listening sockets ports in a
single process, you can write a single ipfw rule to collapse many
incoming ports into a single one, so you only have to open one
listening socket in your program:

ipfw add 1300 fwd,7000 tcp from any to me dst-port 7000-8000

The correct answer to your question really depends on why you need to
open so many ports in the first place.

	Dan Nelson
	dnelson at

More information about the freebsd-questions mailing list