LVS-TUNEL 配置笔记

网络关系如下:

  LVS服务器
      私有IP: 192.168.56.102
      公共IP: 192.168.56.100
  WEB-A服务器
       私有IP:192.168.56.103
       公共IP:192.168.56.100
  WEB-B服务器
       私有IP: 10.108.19.333
       公共IP:  192.168.56.100


 1) 参照<<LVS前期准备工作>>

 2) WEB服务器配置
     a 配置网络
       cd /etc/sysconfig/network-config/
        vi ifcfg-eth0
          ----修改添加----
         IPADDR=192.168.56.103
         NETMASK=255.255.255.0
         GATEWAY=192.168.56.1
         ONBOOT=yes

          cp ifcft-lo ifcfg-tunl0
          vi ifcfg-tunl0
          ----修改改添加------
          name=tunl0
          IPADDR=192.168.56.100
          NETMASK=255.255.255.255
          BORADCAST=192.168.56.100

         /sbin/service network resatart
        route add -host 192.168.56.100 dev tunl0

    b) 解决源地址验证问题
      net.ipv4.conf.tunl0.rp_filter=0
      net.ipv3.conf.all.rp_filter=0

     sysctl -p

     c) 配置ARP抑制
      -----ARP-----
       net.ipv4.conf.tunl0.arp_ignore=1
       net.ipv4.conf.tunl0.arp_announce=2
       net.ipv4.conf.eth0.arp_ignore=1
       net.ipv4.conf.eth0.arp_announce=2

      sysctl -p


    D)  配置IPTABLES
         iptables -F
         iptables -P INPUT DORP
         iptables -P OUTPUT ACCEPT
         iptables -P FORWARD DROP
         iptables -t filter -A INPUT -s 192.168.56.0/24 -j ACCEPT
         /sbin/service  iptables save

  E) 配置应用
      使用httpd,并修改首页内容
       /sbin/service httpd restart

  F) 使用links进行测试

  对WEB-B服务器,同样参照以上配置


3) LVS服务器的配置

   a) 网络配置
     配置私有网络
         vi ifcfg-eth0
       ---------
         IPADDR=192.168.56.102
         NETMASK=255.255.255.0
         GATEWAY=192.168.56.1
      ------------
          vi ifcfg-tunl0
        ----------  
           name=tun0
           IPADDR=192.168.56.100
           NETMASK=255.255.255.0
           GATEWAY=192.168.56.100

         /sbin/service nework restart
         route add -host 192.168.56.100 dev tunl0

   b) #配置网络系统参数

//tunl模式时其实不用关心此参数,但是为了避免干扰所以关闭。但DR模式需要开启转发
       net.ipv4.ip_forward=0
       net.ipv4.conf.tunl0.send_redirects=1
       net.ipv4.conf.default.send_redirects=1
       net.ipv4.conf.all.send_redirects=1
       net.ipv4.conf.eth0.send_redirects=1


     c) 配置IPTABLES
         iptables -F
         iptables -P INPUT DROP    
         iptables -P OUTPUT ACCEPT
         iptables -P FORWARD DROP
         iptables -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
         /sbin/service iptables save

    d)  配置IPVSADM
        ipvsadm -C
        ipvsadm -A -t 192.168.56.100:80 -s rr
        ipvsadm -a -t 192.168.56.100:80 -r 192.168.56.103:80 -i
        ipvsadm -a -t 192.168.56.100:80 -r 192.168.56.104:80 -i
    e)验证测试
      在本机多次访问http://192.168.56.100进行测试


你可能感兴趣的:(网络,LVS,服务器,LVS-TUNEL)