AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1252972
Accepted
user1046658
user1046658
Asked: 2020-06-23 20:16:18 +0800 CST2020-06-23 20:16:18 +0800 CST 2020-06-23 20:16:18 +0800 CST

关于 nc -l 和 nc -lp 的困惑

  • 772

在手册页中nc -l,它说:

It is an error to use this option in conjunction with the -p, -s, or -z options.

但我在网上看到的大多数使用此命令的示例都使用nc -lp [port].

你可以-p用-linnc吗?只是nc -l [port], 是它的正确用法,因为当我在另一个终端上用 连接到它时nc [ip address] [port],它可以工作。此外,当我使用nc -lp [port]并连接到它时nc [ip address] [port],它也可以工作。这两个命令有区别吗?

command-line netcat
  • 2 2 个回答
  • 903 Views

2 个回答

  • Voted
  1. Best Answer
    Eduardo Trápani
    2020-06-23T21:00:04+08:002020-06-23T21:00:04+08:00

    请注意,有两个 netcat 包。nc它们提供的命令的选项也不相同:

    netcat-traditional将此命令显示为主要示例之一:

    nc -l -p port [-options] [hostname] [port]
    

    而netcat-openbsd状态:

     -l      Listen for an incoming connection rather than initiating a connection to a remote
             host.  The destination and port to listen on can be specified either as non-optional
             arguments, or with options -s and -p respectively.  Cannot be used together with -x
             or -z.  Additionally, any timeouts specified with the -w option are ignored.
    

    所以是的,两个命令的作用相同,但您可能会遇到不适用于您的 netcat 版本的示例。例如-e.

    • 2
  2. pa4080
    2020-06-23T20:52:46+08:002020-06-23T20:52:46+08:00

    当您使用监听模式-l时,您必须指定端口。例如:

    nc -l 3000  # Listen at port 3000 to all network interfaces
    
    nc -l4 3000  # Listen at port 3000 to all IPv4 network interfaces
    
    nc -l6 3000  # Listen at port 3000 to all IPv6 network interfaces
    

    所以实际上你不需要额外的选项-p来指示nc命令在哪个端口监听。使用-lp选项的示例可能基于旧版本,nc或者作者没有像您一样阅读手册:) 也可能在使用-lp组合时-p省略选项。

    此外,这里是如何创建一个监听服务,基于nc:如何从命令行监听新端口 Ubuntu Server?

    • 1

相关问题

  • 如何从命令行仅安装安全更新?关于如何管理更新的一些提示

  • 如何从命令行刻录双层 dvd iso

  • 如何从命令行判断机器是否需要重新启动?

  • 文件权限如何工作?文件权限用户和组

  • 如何在 Vim 中启用全彩支持?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve