lost and found ( for me ? )

LVS : configure DSR ( Direct Server Return )

Here are logs when configuring LVS direct server return.

     Client
       |
     L2SW
|eth0      | eth0
LVS      L3SW
|eth1      |eth1
     L2SW
       |
     Server ( httpd )

request packets : client -> LVS -> Server
reply packets : server -> L3SW -> Client

Default GW of http server : L3SW eth1 ( not LVS’s eth1 )

[ L3SW ]

I used CentOS6 as L3SW.
disable rp_filter and enable ip_forward.
# echo 0 > /proc/sys/net/ipv4/conf/eth1/rp_filter
# echo 1 > /proc/sys/net/ipv4/ip_forward

[ LVS ]

install LVS(ipvsadm) over yum
[root@centos7-lvs ~]# cat /etc/centos-release
CentOS Linux release 7.1.1503 (Core)

[root@centos7-lvs ~]# yum install -y ipvsadm

[root@centos7-lvs ~]# echo 1 > /proc/sys/net/ipv4/ip_forward
[root@centos7-lvs ~]# echo 0 > /proc/sys/net/ipv4/conf/eth1/rp_filter

add TCP 80 load balancing rule.
[root@centos7-lvs ~]# ipvsadm -A -t 192.168.122.43:80 -s rr
[root@centos7-lvs ~]# ipvsadm -a -t 192.168.122.43:80 -r 192.168.150.150::80 –g

--
      [packet-forwarding-method]

             -g, --gatewaying  Use gatewaying (direct routing). This  is  the
             default.
--

[root@centos7-lvs ~]# ipvsadm –Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
 -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.122.43::80 rr
 -> 192.168.150.150::80           Route   1      0          0

I would like to add “VIP” as an alias IP, but how can I do that with nmcl?
I will add VIP with ifconfig command.
[root@centos7-lvs ~]# yum install -y net-tools

[root@centos7-lvs ~]# ifconfig eth0:10 192.168.122.43

[ Server ]

on the httpd server,
# iptables -t nat -A PREROUTING -d 192.168.122.43 -j REDIRECT
nf_conntrack version 0.5.0 (16384 buckets, 65:806 max)

You don’t need to configure LVS’s VIP on the server.

start the apache
# /etc/init.d/httpd start

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.