首页 > 代码库 > LVS-DR配置

LVS-DR配置

arp_ignore:接收到arp请求时的响应级别

    级别0(默认):只要本地配置有相应地址就给予响应

    级别1:仅在请求的目标地址配置请求到达的接口上的时候,才给予响应

    配置方式:echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore

arp_announce:定义将自己的地址向外通告时的通告级别

  级别0(默认):将本机接口上的的任何地址向外通告

    级别1:试图仅向目标网络通告与其网络匹配的地址

    级别2:仅将与本地接口上地址匹配的网络进行通告

    配置方式:echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce

规划:Director:VIP:172.16.168.200  DIP:172.16.168.10

      RealServer1: RIP:172.16.168.20

      RealServer2: RIP:172.16.168.30

diretor

    配置网卡eth0:ifconfig eth0 172.16.168.10

             eth0:0:ifconfig eth0:0 172.16.168.200 up

    配置一条特殊路由:route add -host 172.16.168.200 dev eth0:0

    ipvsadm配置:ipvsadm -A -t 172.16.168.200:80 -s rr

                 ipvsadm -a -t 172.16.168.200:80 -r 172.16.168.20 -g

                 ipvsadm -a -t 172.16.168.200:80 -r 172.16.168.30 -g

RealServer

    调整/proc响应参数:echo "1" > /proc/sys/net/ipv4/conf/all/arp_ignore

                       echo "2" > /proc/sys/net/ipv4/conf/all/arp_announce

                       echo "1" > /proc/sys/net/ipv4/conf/eth0/arp_ignore

                       echo "2" > /proc/sys/net/ipv4/conf/eth0/arp_announce

    配置网卡eth0:ifconfig eth0 172.16.168.20

            lo:0:ifconfig lo:0 172.16.168.200 broadcast 172.16.168.200 netmask 255.255.255.255 up (使得lo:0只跟自己在同一个网络内)

    配置一条特殊路由:route add -host 172.16.168.200 dev lo:0(使得目标地址为lo:0地址在响应的时候把lo:0的地址作为源地址,不然会使用eth0的地址作为源地址)

LVS-DR配置