路由DR 模式是什么,第1张

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 255255255255

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

ii) 关于ARP广播:

上面绑定VIP的掩码是”255255255255″,说明广播地址是其本身,那么他就不会将ARP发送到实际的自己该属于的广播域了,这样防止与LVS上VIP冲突,而导致IP冲突。

另外在Linux的Real-server上,需要设置ARP的sysctl选项:(下面是举例说明设置项的)

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

System Interface MAC Address IP Address

HN eth0 00:0c:29:b3:a2:54 1921681810

HN eth3 00:0c:29:b3:a2:68 1921681811

HN eth4 00:0c:29:b3:a2:5e 1921681812

client eth0 00:0c:29:d2:c7:aa 19216818129

当我从19216818129 ping 1921681810时,tcpdump抓包发现:

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

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

sysctl -w netipv4confallarp_filter=1

对于多个接口在相同网段可以设置下面的来防止:

sysctl -w netipv4confallarp_ignore=1

sysctl -w netipv4confallarp_announce=2

还是从19216818129 ping 1921681810时,tcpdump抓包发现:

00:0c:29:d2:c7:aa > ff:ff:ff:ff:ff:ff, ARP, length 60: arp who-has 1921681810 tell 1921681812900:0c:29:b3:a2:54 > 00:0c:29:d2:c7:aa, ARP, length 60: arp reply 1921681810 is-at 00:0c:29:b3:a2:5400:0c:29:d2:c7:aa > 00:0c:29:b3:a2:54, IPv4, length 98: 19216818129 > 1921681810: ICMP echo request, id 32066, seq 1, length 6400:0c:29:b3:a2:54 > 00:0c:29:d2:c7:aa, IPv4, length 98: 1921681810 > 19216818129: ICMP echo reply, id 32066, seq 1, length 6400:0c:29:d2:c7:aa > 00:0c:29:b3:a2:54, IPv4, length 98: 19216818129 > 1921681810: ICMP echo request, id 32066, seq 2, length 6400:0c:29:b3:a2:54 > 00:0c:29:d2:c7:aa, IPv4, length 98: 1921681810 > 19216818129: 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 19216818129 tell 192168181000:0c:29:d2:c7:aa > 00:0c:29:b3:a2:54, ARP, length 60: arp reply 19216818129 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 22 – Always use the best local address for this targetIn 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 announceThe max value from conf/{all,interface}/arp_announce is usedIncreasing 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地址: 2021061100(public local address),172161100(private local address),2021061254(VIP)如果发送到client的ip包产生的arp请求的源地址是2021061254(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://wwwmyeducscn),转载请注明出处:http://wwwmyeducscn/sys/yunwei/LVS-desanzhongmoshiqubiexiangjiehtm

如果出现这种情况,客户端一直连接不上,也许是个人电脑架设了无线热点,开启了ICS网络共享服务。

解决方法:在控制面板—网络和INTERNET—网络和共享中心-更改适配器设置,点击本地连接右键选属性。在本地连接的属性界面,选择共享选项卡,将允许其他网络用户通过此计算机的INTERNET来连接的多选框的勾去掉。然后重启电脑,重新登录客户端即可。

延展阅读:

Dr。COM是一款城市热点拨号软件,而城市热点作为大型互联网宽带计费平台为国内大多数高校以及一些企业所广泛应用,在城市热点全面覆盖地区,没有拨号软件那可谓憾事,因此我们提供了DrCOM拨号软件,让您更方便更快捷地步入宽带互联网的殿堂。注意事项:本程序采用网页拨号模式,由于服务器限制,一般拨号后30分钟会自动断线,如需保持在线可勾选‘开启防断线‘,并在断线时间内填写服务器网页拨号断线时间,点击Home键后台运行,程序将在断线之前重新拨号以保持在线(填写0则程序默认为30分钟)。使用说明:拨号:首先打开WLAN连接Dr。COM热点,接着打开Dr。COM,填写服务器、帐号、密码以及断线时间(如不知道断线时间可填默认30分钟),填写完毕后点击‘拨号‘按钮,显示‘拨号成功!‘即已成功连上外网,程序后台运行(请勿关闭程序,否则防断线功能将关闭)。

DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
网站模板库 » 路由DR 模式是什么

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情