[Ilugc] Occupy a port

Girish Venkatachalam girishvenkatachalam at gmail.com
Thu Aug 24 13:35:42 IST 2006


On 8/24/06, Suresh Ramasubramanian <linux at frodo.hserus.net> wrote:
> Senthil Kumaran S wrote:
> > I want to know how can we make a port be occupied in GNU/Linux.
> >
> > For example I want to make something listen on port 80, 3306, etc
> > ports by not actually running a webserver, mysql, etc respectively.
>
> use netcat

Brilliant idea! Let me elaborate . What you want cannot be achieved on some
systems bcoz if the app uses the setsockopt SO_REUSEPORT, then it
won't recv the error. However for the majority of apps, you can make do with
just this on the command line.

$ nc -l 3306
or
$nc -l -p 3306

I am typing from my OpenBSD machine. So the second one might be
relevant for u. Also bear in mind that sometimes, it listens at
127.0.0.1 instead of ur NAT or global IP. So u need to explore that as
well.

HTH,
Girish


More information about the ilugc mailing list