在HP-UX上使用nettl抓包(转)

HP unix常用抓包方法


    用nettl和netfmt命令配合使用
a. 编辑过滤配置文件
将感兴趣的网络信息过滤出来
配置文件格式如下:
filter.conf:
filter ip_saddr 192.6.2.1
filter ip_daddr 192.6.2.1
filter udp_sport 2049
filter udp_dport 2049
filter tcp_sport 23
filter tcp_dport 23 /* TCP port 23 = telent
b. 启动抓包服务
nettl -start
c. 开始抓包
nettl -tn 0x30800000 -e ns_ls_ip -size 1024 -tracemax 99999 -f /tmp/raw0
d. 停止抓包
nettl -tf -e all
e. 停止抓包服务
nettl -stop
f. 查看抓包内容
netfmt -N -n -l -c /tmp/filter.conf -f /tmp/raw0.TRC000

 

HP-UX 自己提供了抓包工具,nettl 。在tcpdump不能用的时候它(比如tcpdump在HP-UX上就不能抓回环上的包)就派上用场了。总结一下nettl的主要用法,备查。

开始抓包
# nettl -tn all -e all -maxtrace 99999 -f /tmp/tixiang
# nettl -tn loopback -e ns_ls_tcp -maxtrace 99999 -f /tmp/tixiang
# nettl -tn pduin pduout -e ns_ls_loopback -tm 100000 -f /tmp/local
# nettl -tn pduin pduout -e ns_ls_loopback -m 56 -tm 100000 -f /tmp/local
# nettl -tn pduin -e ns_ls_loopback -m 56 -tm 100000 -f /tmp/local
-m size 限制每个包的大小。我们不一定对所有的包都感兴趣,在只对包头干兴趣的时候这个选项就非常有效。
FDB协议使用的包头为16个字节,再加上IP头的20个字节,TCP头的20个字节,也就是我们只需要总共56个字节就能确定一个包的基本信息了。
-e subsytem 要抓包的类型,可以使用 nettl -status 来获取。
ns_ls_loopback
ns_ls_ip
ns_ls_tcp
ns_ls_udp
ns_ls_icmp
-tm maxsize 每个文件的最大大小,如果超过此大小,会使用下一个抓包文件。单位:KB。有效值:100~99999
抓包的输出文件为 /tmp/tixiang.xxxx,使用 ls -l /tmp/tixiang.* 来检查
说明:
在 ns_ls_loopback 上抓包如果指定了pduin 和 pduout 每个包会抓到2份,因为一进一出就是两份。
如果指定 -tn all -e all 一个包也会抓到多份,因为一个包可能属于不同的 subsystem,比如一个tcp包既属于tcp,也属于ip等。
抓的包可以使用wireshark来打开并进行分析。也可以使用HP-UX自带的netfmt来分析。
查看状态及-entity可用的信息:
# nettl -status
停止抓包
# nettl -tf -e all

对包的分析
我们可以使用netfmt来查看捕获的包:
netfmt -N -l -f /tmp/nettl_t* | more
可以过滤我们感兴趣的包,使用 -c 来传入过滤文件
netfmt -N -l -c filter -f /tmp/nettl_t* | more
filter 为过滤文件,文件内容的类似如下:
filter tcp_sport 1234
filter tcp_dport 1234
每一行为一个过滤条件,行与行之间是或的关系。

使用行模式来显示(这种模式下不会看到包的具体数据)
netfmt -N -n -l -1 -f /tmp/nettl_t* | more
在每行的显示前加上时间戳
netfmt -T -n -l -1 -f /tmp/nettl_t* | more
参考:
http://www.compute-aid.com/nettl.html
http://docs.hp.com/en/B2355-60105/nettl.1M.html
http://docs.hp.com/en/B2355-60105/netfmt.1M.html

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/559237/viewspace-695880/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/559237/viewspace-695880/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值