永发信息网

路由DR 模式是什么

答案:2  悬赏:50  手机版
解决时间 2021-02-06 12:34
路由DR 模式是什么
最佳答案
DR模式,即(Direct Routing)直接路由模式
DR模式的网络拓扑:



1) 工作过程: 当一个client发送一个WEB请求到VIP,LVS服务器根据VIP选择对应的real-server的Pool,根据算法,在Pool中选择一台Real-server,LVS在hash表中记录该次连接,然后将client的请求包发给选择的Real-server,最后选择的Real-server把应答包直接传给client;当client继续发包过来时,LVS根据更才记录的hash表的信息,将属于此次连接的请求直接发到刚才选择的Real-server上;当连接中止或者超时,hash表中的记录将被删除。


2) DR模式的几个细节:
1> LVS和Real-server必须在相同的网段:(相同的广播域内)
DR模式在转发client的包时,只修改了包目的MAC地址为选定的Real-server的mac地址,所以如果LVS和Real-server在不通的广播域内,那么Real-server就没办法接收到转发的包。下面是mac地址的修改过程:



2> LVS不需要开启路由转发:
LVS的DR模式不需要开启路由转发功能,就可以正常的工作,出于安全考虑,如果不需要转发功能,最好关闭。


3> ARP问题:
通常,DR模式需要在Real-server上配置VIP,配置的方式为:
/sbin/ifconfig lo:0 inet VIP netmask 255.255.255.255


i) 原因在于,当LVS把client的包转发给Real-server时,因为包的目的IP地址是VIP,那么如果Real-server收到这个包后,发现包的目的IP不是自己的系统IP,那么就会认为这个包不是发给自己的,就会丢弃这个包,所以需要将这个IP地址绑到网卡上;当发送应答包给client时,Real-server就会把包的源和目的地址调换,直接回复给client。


ii) 关于ARP广播:
* 上面绑定VIP的掩码是”255.255.255.255″,说明广播地址是其本身,那么他就不会将ARP发送到实际的自己该属于的广播域了,这样防止与LVS上VIP冲突,而导致IP冲突。
* 另外在Linux的Real-server上,需要设置ARP的sysctl选项:(下面是举例说明设置项的)


假设服务器上ip地址如下所示:


System Interface MAC Address IP Address
HN eth0 00:0c:29:b3:a2:54 192.168.18.10
HN eth3 00:0c:29:b3:a2:68 192.168.18.11
HN eth4 00:0c:29:b3:a2:5e 192.168.18.12
client eth0 00:0c:29:d2:c7:aa 192.168.18.129
当我从192.168.18.129 ping 192.168.18.10时,tcpdump抓包发现:


00:0c:29:d2:c7:aa > ff:ff:ff:ff:ff:ff, ARP, length 60: arp who-has 192.168.18.10 tell 192.168.18.12900:0c:29:b3:a2:5e > 00:0c:29:d2:c7:aa, ARP, length 60: arp reply 192.168.18.10 is-at 00:0c:29:b3:a2:5e00:0c:29:b3:a2:54 > 00:0c:29:d2:c7:aa, ARP, length 60: arp reply 192.168.18.10 is-at 00:0c:29:b3:a2:5400:0c:29:b3:a2:68 > 00:0c:29:d2:c7:aa, ARP, length 60: arp reply 192.168.18.10 is-at 00:0c:29:b3:a2:6800:0c:29:d2:c7:aa > 00:0c:29:b3:a2:5e, IPv4, length 98: 192.168.18.129 > 192.168.18.10: ICMP echo request, id 32313, seq 1, length 6400:0c:29:b3:a2:54 > 00:0c:29:d2:c7:aa, IPv4, length 98: 192.168.18.10 > 192.168.18.129: ICMP echo reply, id 32313, seq 1, length 6400:0c:29:d2:c7:aa > 00:0c:29:b3:a2:5e, IPv4, length 98: 192.168.18.129 > 192.168.18.10: ICMP echo request, id 32313, seq 2, length 6400:0c:29:b3:a2:54 > 00:0c:29:d2:c7:aa, IPv4, length 98: 192.168.18.10 > 192.168.18.129: ICMP echo reply, id 32313, seq 2, length 6400:0c:29:b3:a2:54 > 00:0c:29:d2:c7:aa, ARP, length 60: arp who-has 192.168.18.129 tell 192.168.18.1000:0c:29:d2:c7:aa > 00:0c:29:b3:a2:54, ARP, length 60: arp reply 192.168.18.129 is-at 00:0c:29:d2:c7:aa三个端口都发送了arp的reply包,但是192.168.18.129使用的第一个回应的eth4的mac地址作为ping请求的端口,由于192.168.18.10是icmp包中的目的地址,那么ping的应答包,会从eth0端口发出。


如果Real-server有个多个网卡,每个网卡在不同的网段,那么可以过滤掉非本网卡ARP请求的回应;但是如果多个网卡的ip在一个网段,那么就不行了。


sysctl -w net.ipv4.conf.all.arp_filter=1
对于多个接口在相同网段可以设置下面的来防止:


sysctl -w net.ipv4.conf.all.arp_ignore=1
sysctl -w net.ipv4.conf.all.arp_announce=2
还是从192.168.18.129 ping 192.168.18.10时,tcpdump抓包发现:


00:0c:29:d2:c7:aa > ff:ff:ff:ff:ff:ff, ARP, length 60: arp who-has 192.168.18.10 tell 192.168.18.12900:0c:29:b3:a2:54 > 00:0c:29:d2:c7:aa, ARP, length 60: arp reply 192.168.18.10 is-at 00:0c:29:b3:a2:5400:0c:29:d2:c7:aa > 00:0c:29:b3:a2:54, IPv4, length 98: 192.168.18.129 > 192.168.18.10: ICMP echo request, id 32066, seq 1, length 6400:0c:29:b3:a2:54 > 00:0c:29:d2:c7:aa, IPv4, length 98: 192.168.18.10 > 192.168.18.129: ICMP echo reply, id 32066, seq 1, length 6400:0c:29:d2:c7:aa > 00:0c:29:b3:a2:54, IPv4, length 98: 192.168.18.129 > 192.168.18.10: ICMP echo request, id 32066, seq 2, length 6400:0c:29:b3:a2:54 > 00:0c:29:d2:c7:aa, IPv4, length 98: 192.168.18.10 > 192.168.18.129: ICMP echo reply, id 32066, seq 2, length 6400:0c:29:b3:a2:54 > 00:0c:29:d2:c7:aa, ARP, length 60: arp who-has 192.168.18.129 tell 192.168.18.1000:0c:29:d2:c7:aa > 00:0c:29:b3:a2:54, ARP, length 60: arp reply 192.168.18.129 is-at 00:0c:29:d2:c7:aa看到了么,现在只有eth0会回应arp请求了。


arp报文格式:

请求报文:MAC地址字段是空的。
应答报文:所有字段都又内容。


The arp_announce/arp_ignore reference:


arp_announce – INTEGERDefine different restriction levels for announcing the localsource IP address from IP packets in ARP requests sent oninterface:0 – (default) Use any local address, configured on any interface1 – Try to avoid local addresses that are not in the target’ssubnet for this interface. This mode is useful when targethosts reachable via this interface require the source IPaddress in ARP requests to be part of their logical networkconfigured on the receiving interface. When we generate therequest we will check all our subnets that include thetarget IP and will preserve the source address if it is fromsuch subnet. If there is no such subnet we select sourceaddress according to the rules for level 2.2 – Always use the best local address for this target.In this mode we ignore the source address in the IP packetand try to select local address that we prefer for talks withthe target host. Such local address is selected by lookingfor primary IP addresses on all our subnets on the outgoinginterface that include the target IP address. If no suitablelocal address is found we select the first local addresswe have on the outgoing interface or on all other interfaces,with the hope we will receive reply for our request andeven sometimes no matter the source IP address we announce.The max value from conf/{all,interface}/arp_announce is used.Increasing the restriction level gives more chance forreceiving answer from the resolved target while decreasingthe level announces more valid sender’s information.
arp_announce用来限制,是否使用发送的端口的ip地址来设置ARP的源地址:* “0″代表是用ip包的源地址来设置ARP请求的源地址。* “1″代表不使用ip包的源地址来设置ARP请求的源地址,如果ip包的源地址是和该端口的IP地址相同的子网,那么用ip包的源地址,来设置ARP请求的源地址,否则使用”2″的设置。* “2″代表不使用ip包的源地址来设置ARP请求的源地址,而由系统来选择最好的接口来发送。当内网的机器要发送一个到外部的ip包,那么它就会请求路由器的Mac地址,发送一个arp请求,这个arp请求里面包括了自己的ip地址和Mac地址,而linux默认是使用ip的源ip地址作为arp里面的源ip地址,而不是使用发送设备上面的 ,这样在lvs这样的架构下,所有发送包都是同一个VIP地址,那么arp请求就会包括VIP地址和设备 Mac,而路由器收到这个arp请求就会更新自己的arp缓存,这样就会造成ip欺骗了,VIP被抢夺,所以就会有问题。现在假设一个场景来解释arp_announce:Real-server的ip地址: 202.106.1.100(public local address),172.16.1.100(private local address),202.106.1.254(VIP)如果发送到client的ip包产生的arp请求的源地址是202.106.1.254(VIP),那么LVS上的VIP就会被冲掉,因为交换机上现在的arp对应关系是Real-server上的VIP对应自己的一个MAC,那么LVS上的VIP就失效了。arp_ignore – INTEGERDefine different modes for sending replies in response toreceived ARP requests that resolve local target IP addresses:0 – (default): reply for any local target IP address, configuredon any interface1 – reply only if the target IP address is local addressconfigured on the incoming interface2 – reply only if the target IP address is local addressconfigured on the incoming interface and both with thesender’s IP address are part from same subnet on this interface3 – do not reply for local addresses configured with scope host,only resolutions for global and link addresses are replied4-7 – reserved8 – do not reply for all local addressesThe max value from conf/{all,interface}/arp_ignore is usedwhen ARP request is received on the {interface}
“0″,代表对于arp请求,任何配置在本地的目的ip地址都会回应,不管该arp请求的目的地址是不是接口的ip;如果有多个网卡,并且网卡的ip都是一个子网,那么从一个端口进来的arp请求,别的端口也会发送回应。“1″,代表如果arp请求的目的地址,不是该arp请求包进入的接口的ip地址,那么不回应。“2″,要求的更苛刻,除了”1″的条件外,还必须要求arp发送者的ip地址和arp请求进入的接口的ip地址是一个网段的。(后面略)


本文来自网学网(http://www.myeducs.cn),转载请注明出处:http://www.myeducs.cn/sys/yunwei/LVS-desanzhongmoshiqubiexiangjie.htm
全部回答
DR(Designated Router) 就是指定的路由器 应该还有BDR 你可以在百度里查到的
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
香菜是什么意思
windows2000 server系统怎么备份啊
三年内有十几次性经历,做处女膜修复手术
南宁丽竹学校插花班学费
盐城迎宾馆-网球场怎么去啊,我要去那办事
以下明代建筑,不属于琉璃建筑的是()。A.南京
电水壶烧水声音大是什么原因
关于高速公路车速
毓龙网球俱乐部地址在哪,我要去那里办事
馥郁酒楼地址在哪,我要去那里办事
步步高Vivo s7手机防盗系统如何解除?
rns315还能不能再装个普通蓝牙模块
关于扩张型心肌病的描述不正确的是A.多数病例
感冒咳嗽支气管炎能吃葡萄什么?
乾隆几个老婆
推荐资讯
如何向有联合主键的表中插入数据?并且联合主
小学六年级下册重点句子
六一儿童节送什么礼物给男朋友比较好
求nike zoom sharkly评测
朱自清父亲什么时候死的
一部父子侦探片,貌似父亲死了很久了,儿子靠
小亮读一本书,第一天读了全书的15分之11,还剩
体育生是报综合类大学好还是报体育院校好
罗斯福新政中,既直接提高就业率,缓和社会矛
《逆天邪魔》txt全集下载
北京拍个人艺术写真哪里好?
大家美术学校(佳木斯向阳区)地址好找么,我有
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?