Chinaunix

标题: 怎样写一个抓ip地址的shell? [打印本页]

作者: iloveyoufreebsd    时间: 2003-06-08 09:31
标题: 怎样写一个抓ip地址的shell?
如运行 netstat -nat 会显示很多ip端口等。


怎样来提取这些ip地址,去掉其它内容。

顺便问一下,有没有什么效率高一点的命令来替代netstat -nat 啊?因为在访问量大时运行netstat -nat 要花费很长的时间,望指点。

非常感谢。
作者: mibfeng    时间: 2003-06-08 10:16
标题: 怎样写一个抓ip地址的shell?
-t?有这个option吗?
illegal option - t
作者: bjgirl    时间: 2003-06-08 10:34
标题: 怎样写一个抓ip地址的shell?
in LInux system,use:
netstat -nat|sed -n '4,$p'|awk '{print $5}'
作者: anonimousboy    时间: 2003-06-08 11:19
标题: 怎样写一个抓ip地址的shell?
netstat -n | sed -n '5,/^$/p' | awk 'BEGIN{printf "Local Address     ";printf"Romote Address\n"}{printf"%s",$1 ;printf"   "; printf"%s\n",$2 }' | more
作者: iloveyoufreebsd    时间: 2003-06-08 11:45
标题: 怎样写一个抓ip地址的shell?
谢谢啦,不过看起来有点头晕。:)
作者: iloveyoufreebsd    时间: 2003-06-08 11:49
标题: 怎样写一个抓ip地址的shell?
顺便问一下,有没有什么效率高一点的命令来替代netstat -nat 啊?因为在访问量大时运行netstat -nat 要花费很长的时间,望指点。

非常感谢。
作者: bzzyg    时间: 2003-06-08 14:56
标题: 怎样写一个抓ip地址的shell?
用 ifconfig -a | grep "broadcast"| awk '{ print $2 }' 即可.
作者: iloveyoufreebsd    时间: 2003-06-08 16:44
标题: 怎样写一个抓ip地址的shell?
[quote]原帖由 "bzzyg"]用 ifconfig -a | grep "broadcast"| awk '{ print $2 }' 即可.[/quote 发表:
     

运行后没有结果实:(
作者: bzzyg    时间: 2003-06-08 17:29
标题: 怎样写一个抓ip地址的shell?
是对的啊 我是在sco unix  shell 下运行的.
作者: iloveyoufreebsd    时间: 2003-06-08 17:40
标题: 怎样写一个抓ip地址的shell?
哦,我的系统是 rh 7.3 :(
作者: bjgirl    时间: 2003-06-08 17:49
标题: 怎样写一个抓ip地址的shell?
in Linux,use:
ifconfig|grep inet|awk '{print $2}'|sed -n 's/^.....//p'
作者: 红袖添香    时间: 2003-06-08 18:13
标题: 怎样写一个抓ip地址的shell?
...

ifconfig | awk '/inet/{sub("addr:","";print $2}'
作者: woodie    时间: 2003-06-09 11:13
标题: 怎样写一个抓ip地址的shell?
sed version:
  1. /sbin/ifconfig|sed -ne '/inet/ s/^.*addr:\([0-9.]*\) .*$/\1/p'
复制代码





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2