Site icon moneyslow.com

常用命令

shell技巧

shell技巧

获取公网出口Ip地址的命令:
curl myip.ipip.net
curl cip.cc
curl ipinfo.io
curl ifconfig.me
用curl调试sock5代理:curl -x socks5h://localhost:8001 www.moneyslow.com/
nc走sock5转发: ProxyCommand  /usr/bin/nc -X 5 -x 127.0.0.1:13659 %h %p //连github时
wget不存在的网站:wget -Y on -e "http_proxy=http://**[HTTP_HOST]**:**[HTTP_PORT]**" 网页链接其中:[HTTP_HOST]和[HTTP_PORT]是http proxy的ADDRESS和PORT。
curl指定本地端口连远程(这样抓包只抓这个端口):curl --local-port
nc测试udp能否通(比如overlay网络、dns):nc -v -u -z -w 3 1.1.1.1 53
awk分组统计分析平均值:awk '{ sum[$1]+=$2; count[$1]+=1 ;} END { for (key in count) {  printf  "time= %s  \t count=%s   \t avg=%.6f \n", key,  count[key], sum[key]/count[key] } }’
mac用户备份本地最近修改的文件、配置  将大图压小节省流量:find img_small -size +1024k -type f -exec sips -Z 1024 {} \;
检查用户使用的是长、短连接:netstat -ato
发起ping风暴:ping -f
测试网络MTU:ping -M
带时间戳的ping: ping -D 114.114.114.114 | awk '{ if(gsub(/\[|\]/, "", $1)) $1=strftime("[%F %T]", $1); print}’
长期用来统计抓包中的各种 响应时间,这个时候应用的日志已经不可信了;按URL、时间梯度进行分组统计:
tshark -r 0623.pcap -Y 'http.time>0 ' -T fields -e frame.number -e frame.time_epoch  -e frame.time_delta_displayed  -e ip.src -e ip.dst -e http://tcp.stream  -e http.request.full_uri -e http.response_for.uri  -e http.time  | awk '{ print int($2/10), $8 }' | awk '{ sum[$1]+=$2; count[$1]+=1 ;} END { for (key in count) {  printf  "time= %s  \t count=%s   \t avg=%.6f \n", key,  count[key], sum[key]/count[key] } }' | sort -k2n | gawk '{ print strftime("%c",$2*10), $0 }'
测试邮件外发25端口:
telnet alt3.gmail-smtp-in.l.google.com 25
Exit mobile version