RHEL 6.5

主机名

IP

 所需软件 

master

eth0==>192.168.30.140(Nat)

eth0:1==>192.168.17.130(Nat)

ipvsadm

node-1

eth0==>192.168.17.131

httpd

node-2

eth0==>192.168.17.132

在master上安装及开启ipvsadm

1[root@master ~]# yum install -y ipvsadm 2[root@master ~]# cd /etc/sysconfig/network-scripts/ 3[root@master network-scripts]# cp ifcfg-eth0 ifcfg-eth:1 4[root@master network-scripts]# vim ifcfg-eth0:1 #只需修改绿色部分三处,其他不要动 5DEVICE=eth0:1 6TYPE=Ethernet 7UUID=a186cc9d-8d79-4027-a180-a1b17d884a7b 8ONBOOT=yes 9NM_CONTROLLED=yes 10BOOTPROTO=none 11HWADDR=00:0C:29:4D:47:50 12IPADDR=192.168.30.130 13PREFIX=24 14GATEWAY=192.168.30.2 15DNS1=119.29.29.29 16DEFROUTE=yes 17IPV4_FAILURE_FATAL=yes 18IPV6INIT=no 19NAME="System eth0:1" 20重启网络服务 21[root@master ~]# service network restart 22Shutting down interface eth0: Device state: 3 (disconnected) 23 [ OK ] 24Shutting down interface eth1: [ OK ] 25Shutting down loopback interface: [ OK ] 26Bringing up loopback interface: [ OK ] 27Bringing up interface eth0: Active connection state: activated 28Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1 29 [ OK ] 30[root@master ~]# ifconfig 31eth0 Link encap:Ethernet HWaddr 00:0C:29:4D:47:50 32 inet addr:192.168.30.140 Bcast:192.168.30.255 Mask:255.255.255.0 33 inet6 addr: fe80::20c:29ff:fe4d:4750/64 Scope:Link 34 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 35 RX packets:81 errors:0 dropped:0 overruns:0 frame:0 36 TX packets:105 errors:0 dropped:0 overruns:0 carrier:0 37 collisions:0 txqueuelen:1000 38 RX bytes:8687 (8.4 KiB) TX bytes:8194 (8.0 KiB) 39 40eth0:1 Link encap:Ethernet HWaddr 00:0C:29:4D:47:50 #MAC地址一定要与eth0的一样 41 inet addr:192.168.30.130 Bcast:192.168.30.255 Mask:255.255.255.0 42 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

添加规则

1确保这里是0 2[root@master ~]# sysctl -p 3net.ipv4.ip_forward = 0 4.......... 5添加规则 6[root@master ~]# ipvsadm -A -t 192.168.30.130:80 -s rr 7[root@master ~]# ipvsadm -a -t 192.168.30.130:80 -r 192.168.30.131 -g 8[root@master ~]# ipvsadm -a -t 192.168.30.130:80 -r 192.168.30.132 -g 9[root@master ~]# ipvsadm -L -n 10IP Virtual Server version 1.2.1 (size=4096) 11Prot LocalAddress:Port Scheduler Flags 12 -> RemoteAddress:Port Forward Weight ActiveConn InActConn 13TCP 192.168.30.130:80 rr 14 -> 192.168.30.131:80 Route 1 0 0 15 -> 192.168.30.132:80 Route 1 0 0 16保存规则 17[root@master ~]# /etc/init.d/ipvsadm save 18ipvsadm: Saving IPVS table to /etc/sysconfig/ipvsadm: [ OK ]

在realserver(node-1和node-2)上

1生成ifcfg-lo:1文件 2[root@node-1 ~]# cd /etc/sysconfig/network-scripts/ 3[root@node-1 network-scripts]# cp ifcfg-lo ifcfg-lo:1 4[root@node-1 network-scripts]# vim ifcfg-lo:1 5DEVICE=lo:1 6IPADDR=192.168.30.130 7NETMASK=255.255.255.255 8# If you're having problems with gated making 127.0.0.0/8 a martian, 9# you can change this to something else (255.255.255.255, for example) 10ONBOOT=yes 11NAME=loopback

关闭ARP转发

1[root@node-1 ~]# vim /etc/sysctl.conf #末未添加 2net.ipv4.conf.eth0.arp_ignore = 1 3net.ipv4.conf.eth0.arp_announce = 2 4[root@node-1 ~]# sysctl -p #使立即生效 5net.ipv4.ip_forward = 0 6..... 7net.ipv4.conf.eth0.arp_ignore = 1 8net.ipv4.conf.eth0.arp_announce = 2

修改网关

1[root@node-1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 2GATEWAY=192.168.30.2 3#网关修改为指向外网出口的路由器IP

创建测试页面

[root@node-1 ~]# echo "<h1>This is the node-1 Web-Server:192.168.17.131</h1>" > /var/www/html/index.html

在node-2上

1[root@node-2 ~]# cd /etc/sysconfig/network-scripts/ 2[root@node-2 network-scripts]# cp ifcfg-lo ifcfg-lo:1 3[root@node-2 network-scripts]# vim ifcfg-lo:1 4DEVICE=lo:1 5IPADDR=192.168.30.130 6NETMASK=255.255.255.255 7# If you're having problems with gated making 127.0.0.0/8 a martian, 8# you can change this to something else (255.255.255.255, for example) 9ONBOOT=yes 10NAME=loopback 11[root@node-2 ~]# service network restart 12Shutting down interface eth0: Device state: 3 (disconnected) 13 [ OK ] 14Shutting down interface eth1: [ OK ] 15Shutting down loopback interface: [ OK ] 16Bringing up loopback interface: [ OK ] 17Bringing up interface eth0: Active connection state: activated 18Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/3 19 [ OK ] 20[root@node-2 ~]# ifconfig 21eth0 Link encap:Ethernet HWaddr 00:50:56:2F:84:4D 22 inet addr:192.168.30.132 Bcast:192.168.30.255 Mask:255.255.255.0 23 inet6 addr: fe80::250:56ff:fe2f:844d/64 Scope:Link 24................... 25lo:1 Link encap:Local Loopback 26 inet addr:192.168.30.130 Mask:255.255.255.255 27 UP LOOPBACK RUNNING MTU:16436 Metric:1

关闭ARP转发通node-1操作一样;

创建测试页面

1[root@node-2 ~]# echo "<h1>This is the node-2 Web-Server:192.168.17.132</h1>" > /var/www/html/index.html 2[root@node-2 ~]# service httpd restart 3Stopping httpd: [ OK ] 4Starting httpd: [ OK ]

物理机使用浏览器访问测试

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

关于局域网中的攻击溯源问题

由于目前NAT技术的大量使用,若攻击者主机位于NAT后面,使用私网IP地址,对于攻击源的追踪只能到攻击者的NAT网关,而无法穿透NAT网关。因此,假设已知攻击者来自于某个NAT网关保护的私有网络,如何定位攻击者主机在私网中的位置?这一问题在有线网络比较容易

Keepalived高可用、Keepalived+LVS高可用调度器

Keepalived高可用环境准备:准备三台RHEL7虚拟机,2台做Web服务器(部署Keepalived实现Web服务器的高可用),Web服务器的浮动VIP地址为192.168.4.80,1台作为客户端(proxy)。配置主机名、IP和yum源:1.proxy (eth0:192.

VirtualBox网络NAT模式的端口映射设置

VirtualBox的提供了四种网络接入模式,它们分别是:1、NAT网络地址转换模式(NAT,NetworkAddressTranslation)2、BridgedAdapter桥接模式3、Internal内部网络模式4、HostonlyAdapter主机模式其中NAT模式是最简单的实现虚拟机上网的方式,可以认为