curl请求接口
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"CI_NO":"PWIN2008026"}' 'https://soatest.tp-link.com.cn:7077/TP3CWTEST/GET_TOTAL_TGW_BY_CI_NO'
ping
ping [IP/Host] -- 测试主机连通性
测试链路最大MTU值: ping -l 1472 -f -n 1 [IP/Host], 其中,
-l : 报文字节数,也即MSS(最大报文长度) , MTU(最大传输单元,通常为1500 byte) = MSS + TCP首部(基本大小为20byte) + IP首部(基本大小为20byte) = 1460
-f: 标识IP层不分片(即IP协议中DF标志位置1),若当前经过节点MTU值大于ICMP探测报文大小(ping本质为ICMP探测报文),并且DF标志位为1,则当前节点会直接丢弃该报文,且答复源主机
ICMP TYPE 3 CODE 4报文(Fragmentation needs and DF set);但假如DF标志位为0,标识可进行IP层分片,则报文可依据当前节点MTU值进行分片,顺利通过。TCP建立连接前两次握手时会进行MSS大小磋商,以确定后续数据传输时传输层使用的报文最大大小,通常应不大于MSS值且IP层DF标识位置1,应由TCP来保证应用层数据传输数据的分组与重组
traceroute
telnet
netstat
列出连接信息
-a: 列出当前所有连接( tcp, udp 和 unix 协议下所有套接字的所有连接)
-at: 列出 TCP 协议的连接
-au: 列出 UDP 协议的连接
-tnl: 只列出监听中的TCP连接
-ant: 默认情况下 netstat 会通过反向域名解析技术查找每个 IP 地址对应的主机名,这会降低查找速度,可以使用 -n 选项禁用域名解析功能
显示进程信息
sudo netstat -nltp
使用 -p 选项时,netstat 必须运行在 root 权限之下,不然它就不能得到运行在 root 权限下的进程名,而很多服务包括 http 和 ftp 都运行在 root 权限之下
sudo netstat -nltep
-ep 选项可以同时查看进程名和用户名
统计网络包收发情况
$ netstat -s
Ip:
337338596 total packets received
0 forwarded
0 incoming packets discarded
337338562 incoming packets delivered
329444117 requests sent out
36 reassemblies required
17 packets reassembled ok
15 fragments received ok
31 fragments created
Icmp:
37331 ICMP messages received
309 input ICMP message failed.
ICMP input histogram:
destination unreachable: 5266
timeout in transit: 30
echo requests: 31910
echo replies: 125
116861 ICMP messages sent
0 ICMP messages failed
ICMP output histogram:
destination unreachable: 82161
echo request: 2790
echo replies: 31910
...
显示内核路由信息(与route命令一样)
$ netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
172.29.41.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
0.0.0.0 172.29.41.1 0.0.0.0 UG 0 0 0 eth0
打印网络接口信息(ifconfig类似)
$ netstat -ei
Kernel Interface table
eth0 Link encap:Ethernet HWaddr 00:50:56:90:B5:20
inet addr:172.29.41.175 Bcast:172.29.41.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe90:b520/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:107843877 errors:0 dropped:0 overruns:0 frame:0
TX packets:60002144 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:24099140098 (22.4 GiB) TX bytes:117088850527 (109.0 GiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:269720272 errors:0 dropped:0 overruns:0 frame:0
TX packets:269720272 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:39429889451 (36.7 GiB) TX bytes:39429889451 (36.7 GiB)
显示多播组信息
netstat -g
IPv6/IPv4 Group Memberships
Interface RefCnt Group
--------------- ------ ---------------------
lo 1 all-systems.mcast.net
eth0 1 224.0.0.251
eth0 1 239.77.124.213
eth0 1 all-systems.mcast.net
docker0 1 all-systems.mcast.net
lo 1 ff02::1
eth0 1 ff02::202
eth0 1 ff02::1:ff90:b520
eth0 1 ff02::1
docker0 1 ff02::1:ff08:b3fd
docker0 1 ff02::1
搭配grep 打印active状态的连接netstat -atnp | grep ESTA
查看http,smtp 或 ntp 服务是否在运行sudo netstat -aple | grep ntp
搭配watch 命令监视 active 状态的连接
watch -d -n0 "netstat -atnp | grep ESTA"
搭配awk查看TCP连接状态
netstat -n | awk '/^tcp/ {++state[$NF]} END {for (key in state) print key, "\t", state[key]}'
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。