本文介绍怎样在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  # 不须要配置为1
rp_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.33
net.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服务

# 默认监听8000port
$ 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_announce
arp_announce - INTEGER
Define different restriction levels for announcing the local
source IP address from IP packets in ARP requests sent on
interface:
0 - (default) Use any local address, configured on any interface
1 - Try to avoid local addresses that are not in the target's
subnet for this interface. This mode is useful when target
hosts reachable via this interface require the source IP
address in ARP requests to be part of their logical network
configured on the receiving interface. When we generate the
request we will check all our subnets that include the
target IP and will preserve the source address if it is from
such subnet. If there is no such subnet we select source
address 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 packet
and try to select local address that we prefer for talks with
the target host. Such local address is selected by looking
for primary IP addresses on all our subnets on the outgoing
interface that include the target IP address. If no suitable
local address is found we select the first local address
we have on the outgoing interface or on all other interfaces,
with the hope we will receive reply for our request and
even 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 for
receiving answer from the resolved target while decreasing
the level announces more valid sender's information.

arp_ignore - INTEGER
Define different modes for sending replies in response to
received ARP requests that resolve local target IP addresses:
0 - (default): reply for any local target IP address, configured
on any interface
1 - reply only if the target IP address is local address
configured on the incoming interface
2 - reply only if the target IP address is local address
configured on the incoming interface and both with the
sender's IP address are part from same subnet on this interface
3 - do not reply for local addresses configured with scope host,
only resolutions for global and link addresses are replied
4-7 - reserved
8 - do not reply for all local addresses

The max value from conf/{all,interface}/arp_ignore is used
when ARP request is received on the {interface}

LVS:DR模式(Direct Routing)部署实验的更多相关文章

  1. Ubuntu LVS DR模式生产环境部署

    1.环境说明 系统版本:ubuntu14.04 LVS服务器:14.17.64.3 真实服务器:14.17.64.4-12 VIP:14.17.64.13 部署目的:用户请求14.17.64.13的报 ...

  2. LVS模式一:直接路由模式DR(Direct Routing)

    (一)LVS 一.LVS的了解 LVS(Linux Virtual Server)可以理解为一个虚拟服务器系统. Internet的飞速发展,网络带宽的增长,Web服务中越来越多地使用CGI.动态主页 ...

  3. 一个公网地址部署LVS/DR模式

    http://blog.chinaunix.net/uid-7411781-id-3436142.html 一个公网地址部署LVS/DR模式   网上看了很多关于LVS的文章,在选取2种模式LVS/D ...

  4. LVS DR模式实验

    LVS DR模式实验 三台虚拟机,两个台节点机(Apache),一台DR实验调度机 一:关闭相关安全机制 systemctl stop firewalld iptables -F setenforce ...

  5. LVS DR模式搭建 keepalived lvs

    LVS DR模式搭建• 三台机器 • 分发器,也叫调度器(简写为dir)172.16.161.130 • rs1 172.16.161.131 • rs2 172.16.161.132 • vip 1 ...

  6. CentOS下LVS DR模式负载均衡配置详解

    一安装LVS准备: 1.准备4台Centos 6.2 x86_64 注:本实验关闭 SELinux和IPtables防火墙. 管理IP地址 角色 备注 192.168.1.101 LVS主调度器(Ma ...

  7. Linux centosVMware Linux集群架构LVS DR模式搭建、keepalived + LVS

    一.LVS DR模式搭建 三台机器 分发器,也叫调度器(简写为dir) davery :1.101 rs1 davery01:1.106 rs2 davery02:11.107 vip 133.200 ...

  8. LVS DR模式 负载均衡服务搭建

    LVS 负载均衡 最近在研究服务器负载均衡,阅读了网上的一些资料,发现主要的软件负载均衡方案有nginx(针对HTTP服务的负载均衡),LVS(针对IP层,MAC层的负载均衡).LVS模式工作在网络层 ...

  9. LVS DR模式搭建、keepalived+lvs

    1.LVS DR模式搭建 条件: 即三台机器,在同一内网. 编辑脚本文件:/usr/local/sbin/lvs_dr.sh #! /bin/bashecho 1 > /proc/sys/net ...

  10. lvs之 lvs+nginx+tomcat_1、tomcat_2+redis(lvs dr 模式)

    前提:已经安装好 lvs+nginx+tomcat_1.tomcat_2+redis环境 ,可参考 (略有改动,比如tomcat_1.tomcat_2安装在两台机器上,而不是单机多实例 ,自行稍稍变动 ...

随机推荐

  1. ThinkPHP 3.1.2 视图-1

    一.模板的使用 (重点) a.规则 模板文件夹下[TPL]/[分组文件夹/][模板主题文件夹/]和模块名同名的文件夹[Index]/和方法名同名的文件 [index].html(.tpl) 更换模板文 ...

  2. 10个JavaScript小技巧

    1.变量转换 看起来很简单,但据我所看到的,使用构造函数,像Array()或者Number()来进行变量转换是常用的做法.始终使用原始数据类型(有时也称为字面量)来转换变量,这种没有任何额外的影响的做 ...

  3. asp.net连接ORACLE数据库

    这段时间维护客户的一个系统,该系统使用的是ORACLE数据库,之前开发的时候用的都是MSSQL,并没有使用过ORACLE.这两种数据库虽然都是关系型数据库,但是具体的操作大有不同,这里作下记录. 连接 ...

  4. View中的onTouchEvent()与setOnTouchListener()中的ontouch()方法的事件处理先后顺序

    Touch事件的两种情况 1.覆写View.class中定义的onTouchEvent-->基于事件回调监听方式 @Override public boolean onTouchEvent(Mo ...

  5. 二十三种设计模式及其python实现

    本文源码寄方于github:https://github.com/w392807287/Design_pattern_of_python 参考文献: <大话设计模式>——吴强 <Py ...

  6. HDU 1222 Wolf and Rabbit(gcd)

    HDU 1222   Wolf and Rabbit   (最大公约数)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...

  7. [转载]CSS 创作指南(Beta)(css规范)

    当年还在纠结各种规范的时候,不知道从哪里翻到这个,就让我脱离了css这个规范的苦海了... 反正就是团队和项目合作说的算,选择合适的进行使用就可以了,见到合适的文章,我也会转载过来的 来源 https ...

  8. JQuery隔行变色

    <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> &l ...

  9. JS拖动DIV布局

    方法一: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3 ...

  10. Visual Studio调试技巧 -- Attach to Process #Reprinted#

    from:http://www.cnblogs.com/lyosaki88/p/3481338.html 一般写完代码时,我们通常会启动调试运行一下看看是否正确,启动运行的方式无非是F5-- Star ...