记录《Linux高性能服务器编程》书里面讲解到的若干 shell 命令
arp 命令查看ARP高速缓存:
[root@VM_0_10_centos heliang]# arp -a ? (169.254.128.11) at fe:ee:0b:ca:e5:69 [ether] on eth0 ? (169.254.128.5) at fe:ee:0b:ca:e5:69 [ether] on eth0 ? (169.254.0.15) at fe:ee:0b:ca:e5:69 [ether] on eth0
所有知名应用层协议使用的端口号可以在 /etc/services 文件中找到
cat /etc/servies
tcpdump抓包
tcpdump -i eth0 -ent
DNS服务器IP地址
cat /etc/resolv.conf
根据域名查出ip
[heliang@localhost Desktop]$ host -t A 7haogonglu.com 7haogonglu.com has address 118.89.235.163 [heliang@localhost Desktop]$ host -t A www.baidu.com www.baidu.com is an alias for www.a.shifen.com. www.a.shifen.com has address 112.80.248.75 www.a.shifen.com has address 112.80.248.76
tcpdump观察 ipv4头部结构
tcpdump -ntx -i lo
然后,打开另一个终端,输入下面的 telnet命令
telnet 127.0.0.1
如果你电脑提示,没有telnet命令,请参考这里的文档。
用-s 选项指定要发送的字节数
[heliang@VM_0_10_centos ~]$ ping 7haogonglu.com -s 666 PING 7haogonglu.com (118.89.235.163) 666(694) bytes of data. 674 bytes from 118.89.235.163: icmp_seq=1 ttl=63 time=0.443 ms
只抓取 ICMP 报文
[root@VM_0_10_centos heliang]# tcpdump -ntv -i eth0 icmp tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes IP (tos 0x0, ttl 64, id 27024, offset 0, flags [DF], proto ICMP (1), length 694) 172.21.0.10 > 118.89.235.163: ICMP echo request, id 14038, seq 6, length 674 IP (tos 0x0, ttl 63, id 27024, offset 0, flags [DF], proto ICMP (1), length 694) 118.89.235.163 > 172.21.0.10: ICMP echo request, id 14038, seq 6, length 674