lvs Dr模式(vip与dip、rip在不同网段配置)

lvs Dr模式(vip与dip、rip在不同网段配置)

 

 

一、网络配置

1、realserver1:

[root@Server1 ~]# ifconfig eth2 11.100.46.4/24

[root@Server1 ~]# route add default gw 11.100.46.254

[root@Server1 ~]# ifconfig eth1 192.168.2.3/24 up

 

脚本:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[root@Server1 ~]# vim drauto.sh

 

#!/bin/bash

#

vip=192.168.3.1

interface=”lo:0″

 

case $1 in

start)

echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore

echo 1 > /proc/sys/net/ipv4/conf/eth1/arp_ignore

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

echo 2 > /proc/sys/net/ipv4/conf/eth1/arp_announce

 

ifconfig lo:0 ${vip}/32 broadcast $vip up

route add -host $vip dev $interface

;;

stop)

ifconfig $interface down

echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore

echo 0 > /proc/sys/net/ipv4/conf/eth1/arp_ignore

echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce

echo 0 > /proc/sys/net/ipv4/conf/eth1/arp_announce

esac

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[root@Server1 ~]# ./drauto.sh start

 

2、realserver2:

[root@Server1 ~]# ifconfig eth2 11.100.46.9/24

[root@Server1 ~]# route add default gw 11.100.46.254

[root@server2 ~]# ifconfig eth1 192.168.2.4/24

 

脚本:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[root@Server1 ~]# vim drauto.sh

 

#!/bin/bash

#

vip=192.168.3.1

interface=”lo:0″

 

case $1 in

start)

echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore

echo 1 > /proc/sys/net/ipv4/conf/eth1/arp_ignore

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

echo 2 > /proc/sys/net/ipv4/conf/eth1/arp_announce

ifconfig lo:0 ${vip}/32 broadcast $vip up

route add -host $vip dev $interface

;;

stop)

ifconfig $interface down

echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore

echo 0 > /proc/sys/net/ipv4/conf/eth1/arp_ignore

echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce

echo 0 > /proc/sys/net/ipv4/conf/eth1/arp_announce

esac

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[root@Server1 ~]# ./drauto.sh start

 

3、Director:

[root@Director ~]# ifconfig eth2 192.168.2.2/24

[root@ Director ~]# ifconfig eth2 11.100.46.11/24

[root@ Director ~]# route add default gw 11.100.46.254

[root@Director ~]# ifconfig lo:0 192.168.3.1/32 broadcast 192.168.3.1

[root@Director ~]# route add -host 192.168.3.1 dev lo:0

 

4、router

[root@Router ~]# ifconfig eth2 192.168.2.1/24

[root@ Router ~]# ifconfig eth2 11.100.46.254/24

[root@Router ~]# route add default gw 192.168.2.2

 

二、安装http

[root@Server1 ~]# yum -y install httpd

[root@server2 ~]# service httpd start

 

三、配置lvs调度

[root@Director ~]# ipvsadm -A -t 192.168.3.1:80 -s rr

[root@Director ~]# ipvsadm -a -t 192.168.3.1:80 -r 192.168.2.3 -g

[root@Director ~]# ipvsadm -a -t 192.168.3.1:80 -r 192.168.2.4 –g

四、测试配置

 

你可能感兴趣的:(lvs Dr模式(vip与dip、rip在不同网段配置))