Location>code7788 >text

LVS-TUN Tunnel Mode

Popularity:225 ℃/2024-08-06 17:23:45

Sure. Below is a lab manual in tabular form organized according to your requirements:

Host Name NIC Information Installation of applications systems
Client 192.168.2.101 not have RHEL8/CentOS8
Lvs server (DR) DIP:192.168.2.110
VIP:192.168.40.111
ipvsadm RHEL8/CentOS8
RS1 RIP:192.168.2.111 httpd RHEL8/CentOS8
RS2 RIP:192.168.2.112 httpd RHEL8/CentOS8

Each host here has its own specific features and configurations:

  • Client: Used to initiate a request.
  • Lvs server (DR): Acts as a load balancer, responsible for receiving and distributing traffic.
  • RS1 cap (a poem)RS2: Acts as a real server and handles requests from the load balancer.

Load Balancer (LB)

  1. To save the IPVS configuration.

    ipvsadm --save > /etc/sysconfig/ipvsadm
    
  2. Enable IP Forwarding.

    echo "net.ipv4.ip_forward = 1" >> /etc/
    sysctl -p
    
  3. Configure the TUN interface.

    ifconfig tunl0 192.168.2.200 broadcast 192.168.2.200 netmask 255.255.255.255 up
    
  4. Create a virtual server and set up polling scheduling.

    ipvsadm -A -t 192.168.2.200:80 -s rr
    
  5. Add real servers.

    ipvsadm -a -t 192.168.2.200:80 -r 192.168.2.111:80 -i
    ipvsadm -a -t 192.168.2.200:80 -r 192.168.2.112:80 -i
    
  6. Disabling the firewall with SELinux.

    systemctl stop 
    setenforce 0
    
  7. Verify the IPVS configuration.

    ipvsadm -ln
    

Real Server 1 (RS1)

  1. Start the HTTP service.

    systemctl start httpd
    
  2. Disable SELinux and firewalls.

    setenforce 0
    systemctl stop 
    
  3. Configure site content.

    echo "this is web1" >> /var/www/html/
    
  4. Test site.

    curl 127.0.0.1
    
  5. Configure the TUN interface.

    ifconfig tunl0 192.168.2.200 broadcast 192.168.2.200 netmask 255.255.255.255 up
    
  6. Adjust sysctl settings.

    echo "net..tunl0.arp_ignore = 1" >> /etc/
    echo "net..tunl0.arp_announce = 2" >> /etc/
    echo "net..arp_ignore = 1" >> /etc/
    echo "net..arp_announce = 2" >> /etc/
    echo "net..tunl0.rp_filter = 0" >> /etc/
    echo "net..rp_filter = 0" >> /etc/
    sysctl -p
    

Real Server 2 (RS2)

  1. Start the HTTP service.

    systemctl start httpd
    
  2. Disable SELinux and firewalls.

    setenforce 0
    systemctl stop 
    
  3. Configure site content.

    echo "this is web2" >> /var/www/html/
    
  4. Test site.

    curl 127.0.0.1
    
  5. Configure the TUN interface.

    ifconfig tunl0 192.168.2.200 broadcast 192.168.2.200 netmask 255.255.255.255 up
    
  6. Adjust sysctl settings.

    echo "net..tunl0.arp_ignore = 1" >> /etc/
    echo "net..tunl0.arp_announce = 2" >> /etc/
    echo "net..arp_ignore = 1" >> /etc/
    echo "net..arp_announce = 2" >> /etc/
    echo "net..tunl0.rp_filter = 0" >> /etc/
    echo "net..rp_filter = 0" >> /etc/
    sysctl -p
    

test (machinery etc)

  • Test Load Balancer.

    curl 192.168.2.200
    
    [root@localhost ~]# curl 192.168.2.200
    this is web2
    [root@localhost ~]# curl 192.168.2.200
    this is web1
    [root@localhost ~]# curl 192.168.2.200
    this is web2
    [root@localhost ~]# curl 192.168.2.200
    this is web1
    [root@localhost ~]# curl 192.168.2.200
    this is web2
    [root@localhost ~]# curl 192.168.2.200
    this is web1
    [root@localhost ~]# curl 192.168.2.200
    this is web2
    [root@localhost ~]# curl 192.168.2.200
    this is web1