linux tcptraceroute tcpping安装使用

linux tcptraceroute tcpping安装使用1.首先安装依赖包libpcapyuminstall-ylibpcap2.下载tcptracerouterpm包,并安装rpm-ivhtcptraceroute-1.5-0.beta7.el6.rf.x86_64.rpmtcptraceroute121.46.29.1155810-n-q1tracerouteto121….

大家好,又见面了,我是你们的朋友全栈君。

1.首先安装依赖包libpcap

  yum install -y libpcap

2.下载tcptraceroute rpm包,并安装

  rpm -ivh tcptraceroute-1.5-0.beta7.el6.rf.x86_64.rpm

  tcptraceroute 121.46.29.115 5810 -n -q 1
traceroute to 121.46.9.135 (121.46.9.135), 30 hops max, 60 byte packets
 1  10.0.12.254  1.296 ms
 2  10.1.3.250  2.478 ms
 3  *
 4  180.76.225.253  0.369 ms
 5  182.61.255.2  4.030 ms
 6  182.61.253.121  3.815 ms
 7  182.61.253.163  1.516 ms
 8  103.216.40.75  3.131 ms
 9  121.46.29.115 <syn,ack>  35.470 ms


tcpping脚本
vi tcpping.sh

#!/bin/sh
#
# tcpping: test response times using TCP SYN packets
#          URL: http://www.vdberg.org/~richard/tcpping.html
#
# uses tcptraceroute from http://michael.toren.net/code/tcptraceroute/
#
# (c) 2002-2005 Richard van den Berg <richard@vdberg.org> under the GPL
#               http://www.gnu.org/copyleft/gpl.html
#
# 2002/12/20 v1.0 initial version
# 2003/01/25 v1.1 added -c and -r options
#                 now accepting all other tcptraceroute options
# 2003/01/30 v1.2 removed double quotes around backquotes
# 2003/03/25 v1.3 added -x option, courtesy of Alvin Austin <alvin@crlogic.com>
# 2005/03/31 v1.4 added -C option, courtesy of Norman Rasmussen <norman@rasmussen.org>
# 2007/01/11 v1.5 catch bad destination addresses
# 2007/01/19 v1.6 catch non-root tcptraceroute
# 2008/02/10 v1.7 make -C work when reverse lookup fails, courtesy of Fabrice Le Dorze <Fabrice.LeDorze@apx.fr>


ver="v1.7"
format="%Y%m%d%H%M%S"
d="no"
c="no"
C="no"
ttl=255
seq=0
q=1
r=1
w=3
topts=""

usage () {
    name=`basename $0`
    echo "tcpping $ver Richard van den Berg <richard@vdberg.org>"
    echo
    echo "Usage: $name [-d] [-c] [-C] [-w sec] [-q num] [-x count] ipaddress [port]"
    echo
    echo "        -d   print timestamp before every result"
    echo "        -c   print a columned result line"
    echo "        -C   print in the same format as fping's -C option"
    echo "        -w   wait time in seconds (defaults to 3)"
    echo "        -r   repeat every n seconds (defaults to 1)"
    echo "        -x   repeat n times (defaults to unlimited)"
    echo
    echo "See also: man tcptraceroute"
    echo
}

_checksite() {
    ttr=`tcptraceroute -f ${ttl} -m ${ttl} -q ${q} -w ${w} $* 2>&1`
    if echo "${ttr}" | egrep -i "(bad destination|got roo)" >/dev/null 2>&1; then
        echo "${ttr}"
        exit
    fi
}
    
_testsite() {
    myseq="${1}"
    shift
    [ "${c}" = "yes" ] && nows=`date +${format}`
    [ "${d}" = "yes" ] && nowd=`date`
    ttr=`tcptraceroute -f ${ttl} -m ${ttl} -q ${q} -w ${w} $* 2>/dev/null`
    host=`echo "${ttr}" | awk '{print $2 " " $3}'`
    rtt=`echo "${ttr}" | sed 's/.*] //' | awk '{print $1}'`
    not=`echo "${rtt}" | tr -d ".0123456789"`
    [ "${d}" = "yes" ] && echo "$nowd"
    if [ "${c}" = "yes" ]; then
        if [ "x${rtt}" != "x" -a "x${not}" = "x" ]; then
            echo "$myseq $nows $rtt $host"
        else
            echo "$myseq $nows $max $host"
        fi
    elif [ "${C}" = "yes" ]; then
        if [ "$myseq" = "0" ]; then
            echo -n "$1 :"
        fi
        if [ "x${rtt}" != "x" -a "x${not}" = "x" ]; then
            echo -n " $rtt"
        else
            echo -n " -"
        fi
        if [ "$x" = "1" ]; then
            echo
        fi
    else
        echo "${ttr}" | sed -e "s/^.*\*.*$/seq $myseq: no response (timeout)/" -e "s/^$ttl /seq $myseq: tcp response from/"
    fi
#       echo "${ttr}"
}

while getopts dhq:w:cr:nNFSAEi:f:l:m:p:s:x:C opt ; do
    case "$opt" in
        d|c|C) eval $opt="yes" ;;
        q|w|r|x) eval $opt="$OPTARG" ;;
        n|N|F|S|A|E) topt="$topt -$opt" ;;
        i|l|p|s) topt="$topt -$opt $OPTARG" ;;
        f|m) ttl="$OPTARG" ;;
        ?) usage; exit ;;
    esac
done

shift `expr $OPTIND - 1`

if [ "x$1" = "x" ]; then
    usage
    exit
fi

max=`echo "${w} * 1000" | bc`

if [ `date +%s` != "%s" ]; then
    format="%s"
fi

_checksite ${topt} $*

if [ "$x" = "" ]; then
    while [ 1 ] ; do
        _testsite ${seq} ${topt} $* &
        pid=$!
        if [ "${C}" = "yes" ]; then
            wait $pid
        fi
        seq=`expr $seq + 1`
        sleep ${r}
    done
else
    while [ "$x" -gt 0 ] ; do
        _testsite ${seq} ${topt} $* &
        pid=$!
        if [ "${C}" = "yes" ]; then
            wait $pid
        fi
        seq=`expr $seq + 1`
        x=`expr $x - 1`
        if [ "$x" -gt 0 ]; then
            sleep ${r}
        fi
    done
fi

exit
:wq!

chmod +x tcpping.sh

[root@beijing012033 ~]# ./tcpping.sh 121.46.129.33 5810
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 0: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.456 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 2: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.456 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 1: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.449 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 4: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.519 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 5: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.473 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 3: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.470 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 7: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.528 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 6: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.479 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 9: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.478 ms
seq 8: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.516 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 10: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.452 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 11: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.529 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 12: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.521 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 13: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.404 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 14: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.502 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 15: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.514 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 17: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.515 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 16: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.462 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 18: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.442 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 20: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.518 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 19: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.415 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 21: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.453 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 22: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.461 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets
seq 23: tcp response from 121.46.129.33 (121.46.129.33) <syn,ack>  35.462 ms
traceroute to 121.46.129.33 (121.46.129.33), 255 hops max, 60 byte packets

-d  打印本机每发出一个tcp包的当前时间戳
-c  打印一版纯数字的信息,可以用它来粘贴到excel表格 并制成延时抖动表
-C 另一种格式的纯数字制表信息
-w  设置等待时间(秒)  默认为3秒
-r  设置不管有无tcp包回复,本机间隔多少时间重复发送tcp握手包
这个那啥,可以用作ddos哦?! 
-x 设置本机发送多少次tcp包,默认为空 即无限制重复发送

 

转载于:https://www.cnblogs.com/vincent-liang/p/8528279.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/151485.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • docker设置端口2375

    docker设置端口2375一、系统环境:   在Windows764位上,采用Vmwareworkstation12安装了CenOS7.564位。二、问题   在CentOS7.5里安装了Docker,启动docker服务,输入dockerversion,则出现错误信息:    CannotconnecttotheDockerdatemonattcp://0.0.0…

  • tar打包的时候忽略一些目录[通俗易懂]

    tar打包的时候忽略一些目录[通俗易懂]tar打包的时候忽略版本管理文件目录、日志文件目录、storage/app目录tar-zcvfweb.tar.gzweb–exclude-vcs–exclude=storage/logs–exclude=storage/app

  • java 创建新文件_Java创建新文件[通俗易懂]

    java 创建新文件_Java创建新文件[通俗易懂]创建文件是一种非常常见的IO操作,在这一小节中我们将学习如何在java中创建文件的几个方法。在java中创建文件有三种流行的方法,下面将一个一个地来学习。方法一:使用File.createNewFile()方法java.io.File类可用于在Java中创建新文件。当初始化File对象时,需要提供一个文件名,然后调用createNewFile()方法来在Java中创建新文件。如果创建新文件成功,则…

  • A*算法改进——Any-Angle Path Planning的Theta*算法与Lazy Theta*算法

    A*算法改进——Any-Angle Path Planning的Theta*算法与Lazy Theta*算法

  • 22.IMU和里程计融合

    22.IMU和里程计融合1.概述实际使用中会出现轮子打滑和累计误差的情况,这里单单使用编码器得到里程计会出现一定的偏差,虽然激光雷达会纠正,但一个准确的里程对这个系统还是较为重要2.IMU数据获取IMU即为惯性测量单元,一般包含了三个单轴的加速度计和三个单轴的陀螺仪,简单理解通过加速度二次积分就可以得到位移信息、通过角速度积分就可以得到三个角度,实时要比这个复杂许多2.1PIBOTIMU…

  • AWS EC2文件上传[通俗易懂]

    AWS EC2文件上传[通俗易懂]AWSEC2申请配置、文件上传、nginx安装部署、tomcat安装和项目部署、域名绑定AWSEC2服务器申请配置我这里是参考简书的一篇博客:利用AWS的EC2来搭建属于自己的VPN服务器(MAC平台)在步骤4搭建vpn服务器之前都是可以通用的。非常的详细。文件上传经过以上配置之后应该了解到,使用ssh命令访问aws服务器是会用到其提供的秘钥文件的(我这里是serverK…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号