Bilanciamento di Carico: differenza LVS NAT e LVS DIRECT ROUTING

Ritratto di admin

Vediamo le differenze diconfigurazione nel bilanciamento di carico tra masquerading e routing

Masquerading (LVS NAT)

Il directory risiede su una rete diversa rispetto ai Real Server

Director
ifconfig eth0 192.168.17.110 --> Internet
ifconfig eth1 192.168.18.110 --> Realserver

-->impostazione ipvsadm con il Masquerading
ipvsadm -A -t 192.168.17.110:80 -s rr
ipvsadm -a -t 192.168.17.110:80 -r 192.168.18.1:80 -m
ipvsadm -a -t 192.168.17.110:80 -r 192.168.18.2:80 –m

lvs0# ipvsadm -l
IP Virtual Server version 1.0.6 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.17.110:www rr
-> 192.168.18.2:www Masq 1 0 0
-> 192.168.18.1:www Masq 1 0 0
Realserver1
ifconfig eth0 192.168.18.1
route add default gw 192.168.18.110

Realserver2
ifconfig eth0 192.168.18.2
route add default gw 192.168.18.110

LVS NAT

Routing (LVS Direct Routing)

Il directory risiede sulla stessa rete dei real server

Director
ifconfig eth0 192.168.17.100
ifconfig eth0:0 192.168.17.110 --> predisposta per il routing

-->impostazione ipvsadm con il Routing
ipvsadm -A -t 192.168.17.110:80
ipvsadm -a -t 192.168.17.110:80 -r 192.168.17.130:80 -g
ipvsadm -a -t 192.168.17.110:80 -r 192.168.17.131:80 -g
--> abilitare l'ip forwarding
# echo 1 > /proc/sys/net/ipv4/ip_forward

lvs0:~# ipvsadm -L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.17.110:www wlc
-> 192.168.17.130:www Route 1 0 0
-> 192.168.17.131:www Route 1 0 0

Realserver1
ifconfig eth0 192.168.17.130
route add default gw 192.168.17.110
ifconfig lo:0 192.168.17.110 --> alias di loopback (indispensabile per la configurazione con il routing)

Realserver2
ifconfig eth0 192.168.17.131
route add default gw 192.168.17.110
ifconfig lo:0 192.168.17.110 --> alias di loopback (indispensabile per la configurazione con il routing)

Direct Routing

Tunneling (LVS TUN)

Come configurazione è simile al direct routing si differenzia solo perchè i pacchettti vengono incapsulati dal director e scambiati in un tunnel con i real server.

Director
ifconfig eth0 192.168.17.110
ifconfig eth0:0 192.168.17.120 --> Interfaccia per istruire il tunnel verso i real server

-->impostazione ipvsadm con il Masquerading
ipvsadm -A -t 192.168.17.120:80 -s rr
ipvsadm -a -t 192.168.17.120:80 -r 192.168.17.130:80 -i
ipvsadm -a -t 192.168.17.120:80 -r 192.168.17.131:80 -i
--> abilitare l'ip forwarding
# echo 1 > /proc/sys/net/ipv4/ip_forward

Realserver1
ifconfig eth0 192.168.17.130
ifconfig tunl0 192.168.17.120 netmask 255.255.255.255

Realserver2
ifconfig eth0 192.168.17.131
ifconfig tunl0 192.168.17.120 netmask 255.255.255.255

Tunnel
Risorse
http://www.ultramonkey.org/papers/lvs_tutorial/html/