client ( 192.168.10.14 ) -- VIP 192.168.10.112 LVS 192.168.30.111 -- Web*2 192.168.30.10 , 20
interface IP 192.168.10.225
install LVS
# apt-get install ipvsadm libnl1
|
enable IP forwarding
# echo 1 > /proc/sys/net/ipv4/ip_forward
# echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
|
reflect above settings permanently
# egrep ip_forward /etc/sysctl.conf
net.ipv4.ip_forward=1
|
assign VIP
# ip addr add 192.168.10.112 label eth0:vip dev eth0
# ip addr show eth0 label eth0:vip
inet 192.168.10.112/32 scope global eth0:vip
|
configure LVS with ipvsadm command.
# ipvsadm -A -t 192.168.10.112:80 -s rr
# ipvsadm -a -t 192.168.10.112:80 -r 192.168.30.10:80 -m -w 1
# ipvsadm -a -t 192.168.10.112:80 -r 192.168.30.20:80 -m -w 1
# 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.10.122:80 rr
-> 192.168.30.10:80 Masq 1 0 0
-> 192.168.30.20:80 Masq 1 0 0
|
# ipvsadm -ln --rate
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port CPS InPPS OutPPS InBPS OutBPS
-> RemoteAddress:Port
TCP 192.168.10.112:80 57 342 285 25908 31045
-> 192.168.30.10:80 29 171 143 12957 15525
-> 192.168.30.20:80 29 171 143 12952 15519
|
cap data between client and LVS
# tshark -i eth0 port 80
Capturing on eth0
0.000000 192.168.10.14 -> 192.168.10.112 TCP 74 54695 > http [SYN] Seq=0 Win=14600 Len=0 MSS=1460 SACK_PERM=1 TSval=289451261 TSecr=0 WS=128
0.000591 192.168.10.112 -> 192.168.10.14 TCP 74 http > 54695 [SYN, ACK] Seq=0 Ack=1 Win=14480 Len=0 MSS=1460 SACK_PERM=1 TSval=356120740 TSecr=289451261 WS=32
0.000825 192.168.10.14 -> 192.168.10.112 TCP 66 54695 > http [ACK] Seq=1 Ack=1 Win=14720 Len=0 TSval=289451261 TSecr=356120740
0.000883 192.168.10.14 -> 192.168.10.112 HTTP 180 GET / HTTP/1.1
0.001312 192.168.10.112 -> 192.168.10.14 TCP 66 http > 54695 [ACK] Seq=1 Ack=115 Win=14496 Len=0 TSval=356120740 TSecr=289451261
0.001646 192.168.10.112 -> 192.168.10.14 HTTP 342 HTTP/1.1 200 OK (text/html)
0.001672 192.168.10.112 -> 192.168.10.14 TCP 66 http > 54695 [FIN, ACK] Seq=277 Ack=115 Win=14496 Len=0 TSval=356120741 TSecr=289451261
0.001878 192.168.10.14 -> 192.168.10.112 TCP 66 54695 > http [ACK] Seq=115 Ack=277 Win=15744 Len=0 TSval=289451262 TSecr=356120741
0.002299 192.168.10.14 -> 192.168.10.112 TCP 66 54695 > http [FIN, ACK] Seq=115 Ack=278 Win=15744 Len=0 TSval=289451262 TSecr=356120741
0.002799 192.168.10.112 -> 192.168.10.14 TCP 66 http > 54695 [ACK] Seq=278 Ack=116 Win=14496 Len=0 TSval=356120742 TSecr=289451262
|
cap data between LVS and Web servers
# tshark -i eth1 port 80
Capturing on eth1
0.000000 192.168.10.14 -> 192.168.30.10 TCP 74 54696 > http [SYN] Seq=0 Win=14600 Len=0 MSS=1460 SACK_PERM=1 TSval=289453429 TSecr=0 WS=128
0.000559 192.168.30.10 -> 192.168.10.14 TCP 74 http > 54696 [SYN, ACK] Seq=0 Ack=1 Win=14480 Len=0 MSS=1460 SACK_PERM=1 TSval=356177805 TSecr=289453429 WS=32
0.000816 192.168.10.14 -> 192.168.30.10 TCP 66 54696 > http [ACK] Seq=1 Ack=1 Win=14720 Len=0 TSval=289453429 TSecr=356177805
0.000869 192.168.10.14 -> 192.168.30.10 HTTP 180 GET / HTTP/1.1
0.001283 192.168.30.10 -> 192.168.10.14 TCP 66 http > 54696 [ACK] Seq=1 Ack=115 Win=14496 Len=0 TSval=356177805 TSecr=289453429
0.001685 192.168.30.10 -> 192.168.10.14 HTTP 342 HTTP/1.1 200 OK (text/html)
0.001715 192.168.30.10 -> 192.168.10.14 TCP 66 http > 54696 [FIN, ACK] Seq=277 Ack=115 Win=14496 Len=0 TSval=356177806 TSecr=289453429
0.001922 192.168.10.14 -> 192.168.30.10 TCP 66 54696 > http [ACK] Seq=115 Ack=277 Win=15744 Len=0 TSval=289453430 TSecr=356177806
0.002273 192.168.10.14 -> 192.168.30.10 TCP 66 54696 > http [FIN, ACK] Seq=115 Ack=278 Win=15744 Len=0 TSval=289453430 TSecr=356177806
0.002771 192.168.30.10 -> 192.168.10.14 TCP 66 http > 54696 [ACK] Seq=278 Ack=116 Win=14496 Len=0 TSval=356177807 TSecr=289453430
|
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.