美文网首页
Linux工具netcat用法

Linux工具netcat用法

作者: CodingCode | 来源:发表于2024-07-17 04:11 被阅读0次

netcat创建TCP server和TCP client连接

  1. 安装netcat
$ sudo yum install netcat
  1. 启动TCP server
$ nc -l <port>
  1. 启动TCP client连接
$ echo "Hello" | nc localhost <port>

如果只发送一个消息则:

$ echo "Hello" | nc -N localhost <port>

-N shutdown(2) the network socket after EOF on the input. Some servers require this to finish their work.

  1. 连接TLS端口
$ nc --ssl-cert cert.pem --ssl-key key.pem --ssl-trustfile ca.pem <server> <TLSPort>
  1. 通过proxy访问远程http服务
$ nc <proxy-host> <proxy-port>
CONNECT <server-host>:<host-port> HTTP/1.1
Host: <proxy-host>:<proxy-port>

< HTTP/1.0 200 Connection established

GET /tsam HTTP/1.1
Host: <server-host>:<server-port>
Accept: */*

< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< ...

相关文章

网友评论

      本文标题:Linux工具netcat用法

      本文链接:https://www.haomeiwen.com/subject/tqhlhjtx.html