curl
curl 命令是一个从服务器传输数据,或者向服务器传输数据的工具,支持多种协议:DICT、FILE、FTP、FTPS、GOPHER、HTTP、HTTPS、IMAP、IMAPS、LDAP、LDAPS、MQTT、POP3、POP3S、RTMP、RTMPS、RTSP、SCP、SFTP、SMB、SMBS、SMTP、SMTPS、TELNET、TFTP。curl 命令被设计成无需用户交互即可工作的。更多信息请见 curl(1) — Linux manual page。
ubuntu:~$ curl https://httpbin.org/get{"args": {},"headers": {"Accept": "*/*","Host": "httpbin.org","User-Agent": "curl/7.58.0","X-Amzn-Trace-Id": "Root=1-629c984a-2e1c3936379071cc3f9b3fc4"},"origin": "121.5.122.78","url": "https://httpbin.org/get"}ubuntu:~$ curl -X POST -d 'name=hello' https://httpbin.org/post{"args": {},"data": "","files": {},"form": {"name": "hello"},"headers": {"Accept": "*/*","Content-Length": "10","Content-Type": "application/x-www-form-urlencoded","Host": "httpbin.org","User-Agent": "curl/7.58.0","X-Amzn-Trace-Id": "Root=1-629c98c0-64e567ec62638cda249d4ed5"},"json": null,"origin": "121.5.122.78","url": "https://httpbin.org/post"}
ss
ss 命令被用于输出 Linux 套接字的统计信息。它显示的信息与 netstat 命令类似,并且可以显示更多的 Tcp 和状态信息。更多信息请见 ss(8) — Linux manual page。
ubuntu:~$ sudo ss -lntpState Recv-Q Send-Q Local Address:Port Peer Address:PortLISTEN 0 128 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=10113,fd=12),("nginx",pid=1184,fd=12))LISTEN 0 128 127.0.0.53%lo:53 0.0.0.0:* users:(("systemd-resolve",pid=943,fd=13))LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=1094,fd=3))LISTEN 0 128 0.0.0.0:443 0.0.0.0:* users:(("nginx",pid=10113,fd=11),("nginx",pid=1184,fd=11))LISTEN 0 128 *:9100 *:* users:(("node_exporter",pid=1042,fd=3))LISTEN 0 128 *:1200 *:* users:(("frps",pid=1071,fd=9))LISTEN 0 128 *:8080 *:* users:(("frps",pid=1071,fd=8))LISTEN 0 128 [::]:80 [::]:* users:(("nginx",pid=10113,fd=13),("nginx",pid=1184,fd=13))LISTEN 0 100 *:1234 *:* users:(("java",pid=3640,fd=21))LISTEN 0 128 *:8088 *:* users:(("node",pid=2249,fd=18))LISTEN 0 128 *:7000 *:* users:(("frps",pid=1071,fd=3))LISTEN 0 128 *:9508 *:* users:(("frps",pid=1071,fd=10))
nslookup
nslookup(Name Server Lookup)命令用来从 DNS 中查询域名对应的 ip 地址和其它 DNS 记录信息。
ubuntu:~$ nslookup 3.cnServer: 127.0.0.53Address: 127.0.0.53#53Non-authoritative answer:Name: 3.cnAddress: 106.39.164.153Name: 3.cnAddress: 111.13.28.27
ping
ping 命令用来测试数据包能否通过 IP 网络发送到目标主机。
ping 命令的运行原理是向目标主机发送 ICMP 协议的 ECHO_REQUEST 数据包,等待接收响应的 ECHO_RESPONSE 数据包,然后按响应时间和成功次数估算丢包率和延时。
ubuntu:~$ ping 3.cn -t 4PING 3.cn (106.39.164.153): 56 data bytes64 bytes from 106.39.164.153: icmp_seq=0 ttl=50 time=39.883 ms64 bytes from 106.39.164.153: icmp_seq=1 ttl=50 time=43.923 ms64 bytes from 106.39.164.153: icmp_seq=2 ttl=50 time=39.428 ms64 bytes from 106.39.164.153: icmp_seq=3 ttl=50 time=47.891 ms--- 3.cn ping statistics ---4 packets transmitted, 4 packets received, 0.0% packet lossround-trip min/avg/max/stddev = 39.428/42.781/47.891/3.430 ms
traceroute
traceroute 命令用来显示数据包在 IP 网络上发送到目标主机的路由信息。
tcpdump
tcpdump 命令会打印经过网卡的数据包。
tcpdump -i eth0 -w dump.pcapng命令表示把经过eth0网卡上的数据包保存到dump.pcapng文件中,后续可以使用 Wireshark 打开该文件来分析记录网络数据包。
