首页 > 代码库 > Lvs之NAT、DR、TUN三种模式的应用配置案例
Lvs之NAT、DR、TUN三种模式的应用配置案例
1
2
3
4
5
6
7
8
|
[root@rs1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE= "eth0" BOOTPROTO= static IPADDR= 192.168 . 27.130 NETMASK= 255.255 . 255.0 GATEWAY= 192.168 . 27.128 NM_CONTROLLED= "yes" ONBOOT="yes |
1
2
3
4
5
6
7
8
9
10
|
[root@rs1 ~]# yum install httpd -y [root@rs1 ~]# echo web1 > / var /www/html/index.html [root@rs1 ~]# service httpd start [root@rs2 ~]# yum install httpd -y [root@rs2 ~]# echo web2 > / var /www/html/index.html [root@rs2 ~]# service httpd start [root@rs1 ~]# curl http: //127.0.0.1 web1 [root@rs1 ~]# curl http: //192.168.27.131 web2 |
1
|
[root@LB1 ~]# grep -i ‘ip_vs‘ /boot/config- 2.6 . 32 - 71 .el6.i686 |
1
|
[root@LB1 ~]# yum install ipvsadm -y |
1
2
3
4
|
echo 1 > /proc/sys/net/ipv4/ip_forward ipvsadm -A -t 192.168 . 244.132 : 80 -s rr ipvsadm -a -t 192.168 . 244.132 : 80 -r 192.168 . 27.131 -m ipvsadm -a -t 192.168 . 244.132 : 80 -r 192.168 . 27.130 -m |
1
2
3
|
[root@LB1 html]# ipvsadm -E -t 192.168 . 244.132 : 80 -s wrr [root@LB1 html]# ipvsadm -e -t 192.168 . 244.132 : 80 -r 192.168 . 27.130 -m -w 2 [root@LB1 html]# ipvsadm -e -t 192.168 . 244.132 : 80 -r 192.168 . 27.131 -m -w 1 |
1
2
3
4
5
6
7
8
|
[root@rs1 ~]# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce [root@rs1 ~]# echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce [root@rs1 ~]# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore [root@rs1 ~]# echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore [root@rs1 ~]# service network restart [root@rs1 ~]# ifconfig lo: 0 192.168 . 182.200 netmask 255.255 . 255.255 broadcast 182.168 . 182.200 [root@rs1 ~]# route add -host 192.168 . 182.200 dev lo: 0 [root@rs1 ~]# yum install httpd -y |
1
|
[root@LB1 ~]# ifconfig eth0: 0 192.168 . 182.200 / 24 #在eth0: 0 配置vip |
1
2
3
4
|
[root@LB1 ~]# yum install ipvsadm -y [root@LB1 ~]# ipvsadm -A -t 192.168 . 182.200 : 80 -s rr [root@LB1 ~]# ipvsadm -a -t 192.168 . 182.200 : 80 -r 192.168 . 182.130 -g [root@LB1 ~]# ipvsadm -a -t 192.168 . 182.200 : 80 -r 192.168 . 182.129 -g |
1
2
3
4
5
6
|
yum install ipvsadm -y ifconfig tunl0192. 168.182 . 200 broadcast 192.168 . 182.200 netmask 255.255 . 255.0 up route add -host $VIP dev tunl0 ipvsadm -A -t 192.168 . 182.200 : 80 -s rr ipvsadm -a -t 192.168 . 182.200 : 80 -r 192.168 . 27.130 -i ipvsadm -a -t 192.168 . 182.200 : 80 -r 192.168 . 138.131 -i |
1
2
3
4
5
6
|
ifconfig tunl0 192.168 . 182.200 netmask 255.255 . 255.0 broadcast 192.168 . 182.200 up route add -host 192.168 . 182.200 dev tunl0 echo "1" >/proc/sys/net/ipv4/conf/tunl0/arp_ignore echo "2" >/proc/sys/net/ipv4/conf/tunl0/arp_announce echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce |
Lvs之NAT、DR、TUN三种模式的应用配置案例
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。