LVS/NAT 配置
三台服务器一台作为director, 两台作为real server
Director 有一个外网ip(192.168.31.166) 和一个内网ip(192.168.21.166)
两个real server上只有内网ip(192.168.21.100)和(192.168.21.101) 并且需要把两个real server的内网网关设置为director的内网ip(192.168.21.166)
两个real server 上都安装httpd: yum install -y nginx
Director上安装ipvsadm yum install -y ipvsadm
Direcotr 上 vim/usr/local/sbin/lvs_nat.sh
//增加:
1
2
3
4
5
6
7
8
|
#! /bin/bash # director 服务器上开启路由转发功能: echo 1 > /proc/sys/net/ipv4/ip_forward
# 关闭icmp的重定向 echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects
echo 0 > /proc/sys/net/ipv4/conf/default/send_redirects
echo 0 > /proc/sys/net/ipv4/conf/eth0/send_redirects
echo 0 > /proc/sys/net/ipv4/conf/eth1/send_redirects
|
# director 设置nat防火墙
1
2
3
4
5
6
7
8
9
|
iptables -t nat -F iptables -t nat -X iptables -t nat -A POSTROUTING -s192.168.21.0 /24 -j MASQUERADE
# director设置ipvsadm IPVSADM= '/sbin/ipvsadm'
|
本文转自 sykmiao 51CTO博客,原文链接:http://blog.51cto.com/syklinux/1741458,如需转载请自行联系原作者