国产亚洲av在线,国产高清,欧美激情,国产精品久久久久7777,国产精品人成在线观看,国产精品永久免费视频

IT之道-艾銻知道

您當(dāng)前位置: 主頁 > 資訊動(dòng)態(tài) > 艾銻分享 >

服務(wù)器維護(hù)CentOS7 配置網(wǎng)卡端口鏡像


2020-06-28 21:55 作者:admin

服務(wù)器維護(hù)CentOS7 配置網(wǎng)卡端口鏡像

服務(wù)器維護(hù)小知識(shí)背景

最近一直在研究旁路監(jiān)測(cè),需要設(shè)置一個(gè)源端口鏡像給兩個(gè)目的端口(分別接兩個(gè)監(jiān)測(cè)設(shè)備),無奈ip-com交換機(jī)沒配置明白,研究下使用軟件實(shí)現(xiàn)暫時(shí)代替。

服務(wù)器維護(hù)小知識(shí)環(huán)境

發(fā)行版、內(nèi)核、iptables版本信息如下
[root@ted ~]# uname -a
Linux ted 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@ted ~]# cat /etc/RedHat-release
CentOS Linux release 7.2.1511 (Core)
[root@ted ~]# rpm -qi iptables
Name        : iptables
Version     : 1.4.21
Release     : 17.el7
Architecture: x86_64

配置

部署圖大致如下
 
辦公網(wǎng)某主機(jī)IP: 192.168.118.1(演示時(shí)用的VMware的NAT模式,宿主機(jī))
監(jiān)測(cè)服務(wù)器A網(wǎng)卡eth0:192.168.118.134(演示時(shí)用的VMware的NAT模式,VM)
監(jiān)測(cè)服務(wù)器A網(wǎng)卡eth1:192.168.12.13(演示時(shí)用的VMware的VMnet9,VM)
監(jiān)測(cè)服務(wù)器B網(wǎng)卡eth0:192.168.12.12(演示時(shí)用的VMware的VMnet9,VM)
服務(wù)器維護(hù)小知識(shí)在監(jiān)測(cè)服務(wù)器A上執(zhí)行如下命令
查看路由設(shè)置
[root@ted ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.118.2   0.0.0.0         UG    100    0        0 eth0
192.168.12.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.118.0   0.0.0.0         255.255.255.0   U     100    0        0 eth0
所有192.168.12.0網(wǎng)段的流量都走eth1網(wǎng)卡(此網(wǎng)卡與服務(wù)器B的eth0直連)
配置只需一條命令
[root@ted ~]# iptables -I PREROUTING -t mangle -i eth0 -j TEE --gateway 192.168.12.12
[root@ted ~]# iptables-save
所有eth0的進(jìn)口流量包都會(huì)被復(fù)制一份發(fā)到192.168.12.12上(從路由表上看出,先走eth1網(wǎng)卡,再到服務(wù)器B的eth0)

使用

在服務(wù)器A上用tcpdump抓包(開兩個(gè)終端)
[root@ted ~]# tcpdump -i eth0 tcp port 80 -w A-eth0.pcap
[root@ted ~]# tcpdump -i eth0 tcp port 80 -w A-eth1.pcap
在服務(wù)器B上用tcpdump抓包
[root@min-base ~]# tcpdump -i eth0 tcp port 80 -w B-eth0.pcap
 在服務(wù)器A上開httpd服務(wù)器,用辦公網(wǎng)主機(jī)訪問該服務(wù)
 

服務(wù)器維護(hù)小知識(shí)結(jié)果

監(jiān)測(cè)服務(wù)器A、B都得到了鏡像流量。
這里為了演示,使用“辦公機(jī)訪問服務(wù)器A的httpd服務(wù)”代替“辦公網(wǎng)鏡像流量”,實(shí)際情況應(yīng)該是服務(wù)器A網(wǎng)卡eth0是不配置IP的。
 
服務(wù)器維護(hù)小知識(shí)缺點(diǎn)
iptables-TEE實(shí)現(xiàn)端口鏡像會(huì)改變?cè)碝AC、目的MAC
TODO
在服務(wù)器A上再執(zhí)行一條iptables規(guī)則
[root@ted ~]# iptables -I POSTROUTING -t mangle -o eth0 -j TEE --gateway 192.168.12.12
服務(wù)器維護(hù)小知識(shí)把從eth0出去的流量包都鏡像一份發(fā)到192.168.12.12上就可以啦~~
IT運(yùn)維  我們選擇北京艾銻無限
以上文章由北京艾銻無限科技發(fā)展有限公司整理



相關(guān)文章

IT外包服務(wù)
二維碼 關(guān)閉