Centos7配置DR模式的LVS

实验环境;三台centos7系统的虚拟机,物理主机的虚拟网卡IP和虚拟机的IP保持通路

本次实验物理主机虚拟网卡IP是10.10.10.200

虚拟调度器IP是10.10.10.11;两台web服务器IP分别是10.10.10.12、10.10.10.13

web服务器虚拟IP:10.10.10.100

三台虚拟机配置好IP后分别关闭防火墙并配置好yum源

systemctl stop firewalld

systemctl disable firewalld

虚拟调度器配置:

关闭网卡守护进程

systemctl stop NetworkManager

systemctl disable NetworkManager

创建虚拟网卡子接口 ens33:0

cd /etc/sysconfig/metwork-script/

Centos7配置DR模式的LVS

cp ifcfg-ens33 ifcfg-ens33:0

vim !$

BOOTPROTO=static

DEVICE=ens33:0

ONBOOT=yes

IPADDR=10.10.10.100

NETMASK=255.255.255.0

使配置生效

ifup ens33:0

查看配置是否生效 ifconfig

安装ipvsadm

yum -y install ipvsadm

...

...

 

关闭网卡重定向

vim /etc/sysctl.conf

net.ipv4.conf.all.send_redircts = 0

net.ipv4.conf.default.send_redirects = 0

net.ipv4.conf.ens33.send_redirects = 0

net.ipv4.conf.ens34.send_redirects = 0

刷新配置

sysctl -p

 

重载ipvs模块 modprobe ip_vs

添加ipvs TCP集群与ipvsadm集群子节点

ipvsadm -A -t 虚拟IP:80 -s rr                   添加ipvsTCP集群

ipvsadm -A -t 虚拟IP:80 -r  网站1IP:80         添加ipvsTCP集群

ipvsadm -A -t 虚拟IP:80 -r  网站2IP:80         添加ipvsTCP集群

。。。。。。

。。。。。。

 

ipvsadm -Ln

ipvsadm -s > /etc/sysconfig/ipvsadm  保存配置
servicectl restart ipvsadm   重启服务

                                                                                                                                                                             

服务器配置:

关闭网卡守护进程

systemctl stop NetworkManager

systemctl disable NetworkManager

创建虚拟网卡子接口 lo:0

cd /etc/sysconfig/metwork-script/

 

配置本机回环接口的子接口

[root@localhost network-scripts]# cp ifcfg-lo ifcfg-lo:0

[root@localhost network-scripts]# vim !$

DEVICE=lo:0  修改名称

IPADDR=10.10.10.100  修改IP地址

NETMASK=255.255.255.255  子网掩码设置为32位

NETWORK=127.0.0.0

BROADCAST=127.255.255.255

ONBOOT=yes

NAME=loopback

关闭ARP响应公告

[root@localhost network-scripts]# vim /etc/sysctl.conf

net.ipv4.conf.all.arp_ignore = 1

net.ipv4.conf.all.arp_announce = 2

net.ipv4.conf.default.arp_ignore = 1

net.ipv4.conf.default.arp_announce = 2

net.ipv4.conf.lo.arp_ignore = 1

net.ipv4.conf.lo.arp_announce = 2

刷新设置

[root@localhost network-scripts]# sysctl -p

net.ipv4.conf.all.arp_ignore = 1

net.ipv4.conf.all.arp_announce = 2

net.ipv4.conf.default.arp_ignore = 1

net.ipv4.conf.default.arp_announce = 2

net.ipv4.conf.lo.arp_ignore = 1

net.ipv4.conf.lo.arp_announce = 2

启用配置

[root@localhost network-scripts]# ifup lo:0

设置路由 目标地址为10.10.10.100的数据指向网卡lo:0

[root@localhost network-scripts]# route add -host 10.10.10.100 def lo:0

测试网站1

echo “XXXXX01”  >>  /var/www/html/index.html

测试网站2

echo “XXXXX02”  >>  /var/www/html/index.html

两台网站服务器配置完成后用物理机测试10.10.10.100

 


上一篇:ARP报文详解


下一篇:提取数据