实验环境
实验步骤
client 配置
[root@client 18:49:17 ~]
TYPE="Ethernet"
BOOTPROTO="static"
IPADDR=192.168.3.7
NETMASK=255.225.255.0
GATEWAY=192.168.3.17
DEFROUTE="yes"
NAME="eth0"
DEVICE="eth0"
ONBOOT="yes"
[root@client 18:49:21 ~]
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:75:c9:9a brd ff:ff:ff:ff:ff:ff
inet 192.168.3.7/24 brd 192.168.3.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe75:c99a/64 scope link
valid_lft forever preferred_lft forever
router配置
网络配置
[root@router 18:54:51 ~]
TYPE="Ethernet"
BOOTPROTO="static"
IPADDR=192.168.38.17
NETMASK=255.225.255.0
DEFROUTE="yes"
NAME="eth0"
DEVICE="eth0"
ONBOOT="yes"
[root@router 18:56:59 ~]
TYPE="Ethernet"
BOOTPROTO="static"
IPADDR=192.168.3.17
NETMASK=255.225.255.0
DEFROUTE="yes"
NAME="eth1"
DEVICE="eth1"
ONBOOT="yes"
[root@router 18:57:51 ~]
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:0a:53:ba brd ff:ff:ff:ff:ff:ff
inet 192.168.38.17/24 brd 192.168.38.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe0a:53ba/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:0a:53:c4 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.17/24 brd 192.168.3.255 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe0a:53c4/64 scope link
valid_lft forever preferred_lft forever
[root@router 18:59:23 ~]
net.ipv4.ip_forward = 1
[root@router 18:59:37 ~]
net.ipv4.ip_forward = 1
[root@router 19:00:03 ~]
1
webserver配置
webserver1配置
网络配置
[root@webserver1 19:06:33 ~]
TYPE="Ethernet"
BOOTPROTO="static"
IPADDR=192.168.38.37
NETMASK=255.225.255.0
GATEWAY=192.168.38.100
DEFROUTE="yes"
NAME="eth0"
DEVICE="eth0"
ONBOOT="yes"
[root@webserver1 19:08:53 ~]
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:da:5f:ec brd ff:ff:ff:ff:ff:ff
inet 192.168.38.37/24 brd 192.168.38.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:feda:5fec/64 scope link
valid_lft forever preferred_lft forever
web配置
[root@webserver1 19:08:53 ~]
[root@webserver1 19:09:49 ~]
[root@webserver1 19:10:12 ~]
RS1
[root@webserver1 19:10:27 ~]
webserver2配置
网络配置
[root@webserver2 07:11:36 ~]
TYPE="Ethernet"
BOOTPROTO="static"
IPADDR=192.168.38.47
NETMASK=255.225.255.0
GATEWAY=192.168.38.100
DEFROUTE="yes"
NAME="eth0"
DEVICE="eth0"
ONBOOT="yes"
web配置
[root@webserver2 07:12:47 ~]
[root@webserver2 07:13:32 ~]
[root@webserver2 07:13:45 ~]
RS2
[root@webserver2 07:14:06 ~]
LVS配置
网络配置
[root@lvs 19:26:01 ~]
TYPE="Ethernet"
BOOTPROTO="static"
IPADDR=192.168.38.27
NETMASK=255.225.255.0
GATEWAY=192.168.38.17
DEFROUTE="yes"
NAME="eth0"
DEVICE="eth0"
ONBOOT="yes"
[root@lvs 19:26:05 ~]
TYPE="Ethernet"
BOOTPROTO="static"
IPADDR=192.168.38.100
NETMASK=255.225.255.0
GATEWAY=192.168.38.17
DEFROUTE="yes"
NAME="eth1"
DEVICE="eth1"
ONBOOT="yes"
[root@lvs 19:28:43 ~]
net.ipv4.ip_forward = 1
[root@lvs 19:29:15 ~]
net.ipv4.ip_forward = 1
[root@lvs 19:29:24 ~]
1
[root@lvs 19:27:41 ~]
[root@lvs 20:13:48 ~]
[root@lvs 20:15:26 ~]
[root@lvs 20:16:04 ~]
[root@lvs 20:16:11 ~]
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.38.27:80 rr
-> 192.168.38.37:80 Masq 1 0 0
-> 192.168.38.47:80 Masq 1 0 0
客户机测试
[root@client 20:24:27 ~]
RS1
RS2
RS1
RS2
RS1
RS2
RS1
RS2
RS1
RS2
RS1
RS2