Netcat: using nc -l port_number instead of nc -l -p port_number

后端 未结 2 822
北海茫月
北海茫月 2021-01-13 11:04

This question is following this one: Sockets working in openSUSE do not work in Debian?

When working with sockets on my Debian system, I have to use nc -l -p port_nu

2条回答
  •  没有蜡笔的小新
    2021-01-13 11:34

    I agree with duskwuff that it is better to just use the -p option everywhere, but to answer your question:

    The one thing you have to do is install a netcat that supports the syntax you want. I know the netcat-openbsd package supports it. I know the netcat-traditional package does not. There's also a netcat6 package, which also doesn't. You can then explicitly request the OpenBSD version of netcat like so:

    nc.openbsd -l 4242
    

    Optionally you may use the alternatives system to set this version of netcat to run when you issue the nc command:

    update-alternatives --set nc /bin/nc.openbsd
    

    This will be done automatically for you if this is the only netcat you've installed.

    Finally, you may, again optionally, remove the netcat you don't like (netcat-traditional or netcat6).

提交回复
热议问题