设为首页 收藏本站
查看: 1290|回复: 0

[经验分享] LVS:DR模式(Direct Routing)部署实验

[复制链接]

尚未签到

发表于 2015-11-20 14:55:40 | 显示全部楼层 |阅读模式
  本文介绍如何在kvm的虚拟环境下,部署实验LVS的DR模式。包括网络结构图,如何配置,以及使用tcpdump分析ip包。
网络结构图
                              kvm节点(client)                               192.168.7.2 (CIP)
                                           |                                          br_e网桥                                 /                     \
                       (VIP)
         eth7:192.168.7.33      eth14: 192.168.7.99          lvs虚拟主机                      server虚拟主机
                    (DIP)                         (RIP)
         eth8:192.168.88.10     eth12: 192.168.88.20
                                    \                      /                                         br_lvs网桥

实验步骤
1.创建bridge:br_e和br_lvs,并分别设置ip
# kvm节点$ ifconfig br_e 192.168.7.2 netmask 255.255.255.0
2.lvs配置
$ ipvsadm -A -t 192.168.7.33:8000 -s rr$ ipvsadm -a -t 192.168.7.33:8000 -r 192.168.88.20 -g
3.server配置
# 让主机处理dst为192.168.7.33的ip包# 子网掩码必须是255.255.255.255,如果是255.255.255.0则不会处理ip包$ ifconfig lo:0 192.168.7.33 netmask 255.255.255.255 up
/etc/sysctl.conf配置(好像不需要设置?)ip_forward=0  # 不需要配置为1rp_filter = 0   # 默认配置
# 解决arp问题# 官方文档说lo不需要设置arp# 注销后没问题# net.ipv4.conf.lo.arp_ignore = 0# net.ipv4.conf.lo.arp_announce = 0# eth14是br_e上的网卡# 只有当arp请求的目标ip和eth14上绑定ip相同时,eth14才会处理# 否则lvs的vip会和server的vip冲突# 在本例中,br_e网络中会存在两个192.168.7.33net.ipv4.conf.eth14.arp_ignore = 1# 用于eth14发送arp请求时src ip?net.ipv4.conf.eth14.arp_announce = 2# net.ipv4.conf.all.arp_ignore = 1# net.ipv4.conf.all.arp_announce = 2

4.在server虚拟主机上开启web服务
# 默认监听8000端口$ python -m SimpleHTTPServer
5.在kvm节点(client)上
$ curl http://192.168.7.33:8000
tcpdump分析IP包
[kvm send: br_e] 发出ip包(syn)
00:1a:a0:21:21:65 > de:ad:be:ef:24:46, 192.168.7.2.51091 > 192.168.7.33.8000: Flags [S], seq 3773377896

[lvs recv: br_e]lvs收到ip包
00:1a:a0:21:21:65 > de:ad:be:ef:24:46, 192.168.7.2.51091 > 192.168.7.33.8000: Flags [S], seq 3773377896,

[lvs send: br_lvs] lvs修改ip包的mac,目标mac改成server的mac
00:16:3e:5d:a6:b3 > 52:54:00:ba:3d:b9
, 192.168.7.2.51091 > 192.168.7.33.8000: Flags [S], seq 3773377896,

[server recv: br_lvs] server接收ip包(mac相同)
00:16:3e:5d:a6:b3 > 52:54:00:ba:3d:b9, 192.168.7.2.51091 > 192.168.7.33.8000: Flags [S], seq 3773377896

[server send: br_e] server发出ip包(ack) ,ip包的src是lvs的ip, dst是client的ip
52:54:00:c1:a7:5e > 00:1a:a0:21:21:65
, 192.168.7.33.8000 > 192.168.7.2.51091: Flags [S.], seq 3629588945, ack 3773377897

[kvm recv: br_e] client收到ip包(ack)
52:54:00:c1:a7:5e > 00:1a:a0:21:21:65, 192.168.7.33.8000 > 192.168.7.2.51091: Flags [S.], seq 3629588945, ack 3773377897

arp_ignore和arp_announcearp_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_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 addresses
The max value from conf/{all,interface}/arp_ignore is usedwhen ARP request is received on the {interface}

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-141577-1-1.html 上篇帖子: [转]LVS高可用方案汇总 下篇帖子: LVS小试
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表