zoukankan      html  css  js  c++  java
  • Linux高性能服务器编程,书中的 shell 命令

    记录《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

    tcpdump抓取某个端口的数据

    tcpdump  -n  -i  eth0  port  23  

    nc 网络命令,监听12345端口数据(没有这个命令的,需要安装:    yum  install  -y   nc

    nc  -p  12345  127.0.0.1

    iperf网络工具,没有的需要安装 

    yum   -y   install   iperf
    
    iperf  -s 

    修改squid配置文件

    vi   /etc/squid/squid.conf

    telnet 远程登录

    telnet  192.168.12.10  23 

    查看某个端口网络状态

    netstat  -nt | grep  23

    可以通过修改内核参数来快速回收被关闭的socket

    vi  /proc/sys/net/ipv4/tcp_tw_recycle 

    修改内核参数,来强制TCP接收缓冲区和发送缓冲区的大小没有限制

    vi  /proc/sys/net/ipv4/tcp_rmem 
    
    vi  /proc/sys/net/ipv4/tcp_wmen

    监听某个端口的数据情况

     tcpdump -nt -i eth0 port 12345

    tcpdump -nt -i eth0 port 12345
    
    IP 192.168.1.101.41308 > 192.168.1.100.italk: Flags [S], seq 1549300689, win 29200, options [mss 1460,sackOK,TS val 2165838 ecr 0,nop,wscale 7], length 0
    
    IP 192.168.1.100.italk > 192.168.1.101.41308: Flags [S.], seq 4085419987, ack 1549300690, win 1448, options [mss 1460,sackOK,TS val 2095126 ecr 2165838,nop,wscale 7], length 0
    
    IP 192.168.1.101.41308 > 192.168.1.100.italk: Flags [.], ack 1, win 229, options [nop,nop,TS val 2165839 ecr 2095126], length 0
    
    IP 192.168.1.101.41308 > 192.168.1.100.italk: Flags [P.], seq 1:513, ack 1, win 229, options [nop,nop,TS val 2165839 ecr 2095126], length 512
    
    IP 192.168.1.100.italk > 192.168.1.101.41308: Flags [.], ack 513, win 8, options [nop,nop,TS val 2095126 ecr 2165839], length 0
    
    IP 192.168.1.101.41308 > 192.168.1.100.italk: Flags [F.], seq 513, ack 1, win 229, options [nop,nop,TS val 2165839 ecr 2095126], length 0
    
    IP 192.168.1.100.italk > 192.168.1.101.41308: Flags [F.], seq 1, ack 514, win 12, options [nop,nop,TS val 2095127 ecr 2165839], length 0
    
    IP 192.168.1.101.41308 > 192.168.1.100.italk: Flags [.], ack 2, win 229, options [nop,nop,TS val 2165840 ecr 2095127], length 0

     gethostbyname通常先在本地 /etc/hosts 配置文件中查找主机,如果没有找到,再去访问DNS服务器

    vi  /etc/hosts

    ----

  • 相关阅读:
    Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0.
    旋转二维数组
    replace empty char with new string,unsafe method和native implementation的性能比较
    判断一字符串是否可以另一字符串重新排列而成
    移除重复字符的几个算法简单比较
    也来纠结一下字符串翻转
    判断重复字符存在:更有意义一点
    程序员常去网站汇总
    sublime
    针对程序集 'SqlServerTime' 的 ALTER ASSEMBLY 失败,因为程序集 'SqlServerTime' 未获授权(PERMISSION_SET = EXTERNAL_ACCESS)
  • 原文地址:https://www.cnblogs.com/music-liang/p/11882814.html
Copyright © 2011-2022 走看看