因為需要用Wireshark進行遠程抓包,需要在遠程主機上安裝相應的rpcapd服務。Windows上只要安裝WinPcap軟體就行了,它已經包含了rpcapd服務,只要啟動就行了。但Linux上需要自己編譯。
註:Wireshark支援remote packet capture protocol協議遠程抓包,只要在遠程主機上安裝相應的rpcapd服務常式就可以。
安裝命令如下:
yum install glibc-staticwget http://www.winpcap.org/install/bin/WpcapSrc_4_1_2.zipunzip WpcapSrc_4_1_2.zipcd winpcap/wpcap/libpcapchmod +x configure runlex.shCFLAGS=-static ./configuremakecd rpcapdmake
然後
./rpcapd -n
就運行rpcap服務了。
但是,運行./rpcapd -n報如下錯誤
[root@iZ23gx7o02aZ rpcapd]# ./rpcapd -nPress 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 saveiptables: 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 saveiptables: 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 restartiptables: 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 -nPress CTRL + C to stop the server...socket(): Address family supported by protocol (code 98)
修改成功。