日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

tcping在linux用法,tcping的安装和使用

發布時間:2025/3/12 linux 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 tcping在linux用法,tcping的安装和使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Tcping 網上比較少資料是關于linux對tcp端口ping測試的方法,我這里簡單介紹2種方法: 1.yum安裝,編譯安裝方法 1-1.wget http://linuxco.de/tcping/tcping-1.3.5.tar.gz ###下載tcping

1-2 tar zxvf tcping-1.3.5.tar.gz ####解壓縮tcping-1.3.5

1-3 cd tcping-1.3.5 ###進入文件夾

1-4 gcc -o tcping tcping.c ####編譯執行文件

1-5 ./tcping www.baidu.com 80 ####使用方法,后面加tcp端口

2.通過shell腳本,執行tcping命令(能長ping) 2-1 腳本如下: #!/bin/sh

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 " 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} [ "$ozvdkddzhkzd" = "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" [ "$ozvdkddzhkzd" = "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 (time out)/" -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

2-2 vi一個文件,這里命名為tcping

2-3 chmod 777 tcping ###賦予tcping執行權限

2-4 安裝腳本執行內容所需軟件支持

1.wget

2.rpm -ih tcptraceroute-1.5-0.beta7.el6.rf.x86_64.rpm

2-6 ./tcping www.baidu.com 80 ####執行shell腳本

由睿江云運維人員提供,想了解更多,請登陸www.eflycloud.com

總結

以上是生活随笔為你收集整理的tcping在linux用法,tcping的安装和使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。