CentOS下的抓包服务:rpcapd(WinPcap)

因为需要用Wireshark进行远程抓包,需要在远程主机上安装相应的rpcapd服务。
Windows上只要安装WinPcap软件就行了,它已经包含了rpcapd服务,只要启动就行了。但Linux上需要自己编译。 
注:Wireshark支持 remote packet capture protocol协议远程抓包,只要在远程主机上安装相应的 rpcapd 服务例程就可以。
安装命令如下:

yum install glibc-static flex
wget http://www.winpcap.org/install/bin/WpcapSrc_4_1_2.zip
unzip WpcapSrc_4_1_2.zip
cd winpcap/wpcap/libpcap
chmod +x configure runlex.sh
CFLAGS=-static ./configure
make
cd rpcapd
make

然后

./rpcapd -n


就运行rpcap服务了。

但是,运行./rpcapd -n报如下错误

[root@iZ23gx7o02aZ rpcapd]# ./rpcapd -n
Press CTRL + C to stop the server...
socket(): Address family not supported by protocol (code 97)


原因:在linux上,端口有可能没有开放,这时需要修改iptables服务的配置来开放2002端口。
解决办法:
1. CentOS下/etc/sysconfig/下找不到iptables文件
2. Linux中iptables配置详细(转)
参考Linux中iptables配置详细(转)修改iptables服务的配置来开放2002端口。

首先要做的是给咱的SSH进行ACCEPT配置,以免直接无法连接的情况发生:

1. 如果SSH端口是22(这里不建议用默认端口最好改掉SSH端口)

iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT


注意要/etc/rc.d/init.d/iptables save,以下每一步都最好执行一遍此语句,以下不再累述。

[root@iZ23gx7o02aZ sysconfig]# iptables -A INPUT -p tcp --dport 22 -j ACCEPT
[root@iZ23gx7o02aZ sysconfig]# iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
[root@iZ23gx7o02aZ sysconfig]# /etc/rc.d/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[root@iZ23gx7o02aZ sysconfig]#


2. 修改iptables开放2002端口 

iptables -A INPUT -p tcp --dport 2002 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 2002 -j ACCEPT


最后注意需要再执行一下 /etc/init.d/iptables save,这样这两条语句就保存到刚才那个/etc/sysconfig/iptables 文件中了。

[root@iZ23gx7o02aZ sysconfig]# iptables -A INPUT -p tcp --dport 2002 -j ACCEPT
[root@iZ23gx7o02aZ sysconfig]# iptables -A OUTPUT -p tcp --sport 2002 -j ACCEPT
[root@iZ23gx7o02aZ sysconfig]# /etc/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[root@iZ23gx7o02aZ sysconfig]# 


3. 查看iptables的内容

[root@iZ23gx7o02aZ sysconfig]# vi iptables

  1 # Generated by iptables-save v1.4.7 on Wed Dec 10 21:20:39 2014
  2 *filter
  3 :INPUT ACCEPT [4602:266675]
  4 :FORWARD ACCEPT [0:0]
  5 :OUTPUT ACCEPT [5004:417513]
  6 -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
  7 -A INPUT -p tcp -m tcp --dport 2002 -j ACCEPT
  8 -A OUTPUT -p tcp -m tcp --sport 22 -j ACCEPT
  9 -A OUTPUT -p tcp -m tcp --sport 2002 -j ACCEPT
 10 COMMIT
 11 # Completed on Wed Dec 10 21:20:39 2014


4. 重启iptables
重启指令:

service iptables restart

[root@iZ23gx7o02aZ sysconfig]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
[root@iZ23gx7o02aZ sysconfig]# 


5. 运行./rpcapd -n

[root@iZ23gx7o02aZ rpcapd]# ./rpcapd -n
Press CTRL + C to stop the server...
socket(): Address family supported by protocol (code 98)


修改成功!

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

查里王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值