Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Deployment of NAT (Network address) working Mode of lvs (linux Virtual Server)

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Workflow flow chart of LVS-NAT:

1: when a user makes a request, the request first goes to the prerouteing chain of the load balancer dispatcher to determine whether the target ip is always native IP.

2: then the request reaches the input chain and will be compared with the defined cluster service recorded by the ipvs on the input chain. If the user request is the defined cluster service, the ipvs will forcibly change the packet target IP requested by the user.

After 3:postrouteing (routed) receives the packet, it compares the IP of the packet with the back-end server and finds that it happens to be the back-end server, and then sends the request to the back-end server.

In short, after the user makes a request, change the target IP on the packet sent by the user to the back-end server IP on the load balancer, and send the data to the back-end server for processing. After processing, the back-end server sends the packet to the load balancer, and the load balancer changes the destination IP of the packet to its own IP, and then sends the packet to the user.

Build lvs-nat on the server:

Prepare three virtual machines:

192.168.11.11 (node11)-> acts as a load balancer

192.168.11.12 (node12)-> back-end server (RS)

192.168.11.13 (node13)-> back-end server (RS)

Prepare the backend server first: (node13,node12 operation is as follows)

1: install the appache server and prepare to visit the page of the backend server:

Yum-y install httpd-install apache

Systemctl restart httpd-allow self-booting

Echo "welcome to node12" > / var/www/html/index.html-sets the page content

Vim / etc/sysconfig/network-script/ifcfg-enss33

Getway=192.168.11.11-> just change the gateway

Systemctl restart network-> restart the network service

-backend ready (node12 node13)-

Prepare load balancer and node11

1: add a network card to the virtual machine and node11 first

2: configure ip for the newly added Nic

Ifconfig-> found that a new ens37 network card has been added

Cd / etc/sysconfig/network-script/ifcfg-ens37

Cp-v ifcfg-ens3 ifcfg-ens37

Vim ifcfg-ens77

Systemcrl restart network-> restart the network service

3: enable route forwarding temporarily:

Echo 1 > / proc/sys/net/ipv4/ip_forward

4: create a load balancer cluster:

Yum-y install ipvasdm-> install software

Ipvsadm-Ln-> View the cluster (empty at this time)

(IPvsadm-C clears the cluster)-> Don't do it.

Ipvasdam-A-t 192.168.10.11 VIP 80-s rr add load balancer to the cluster

Ipvasdam-a-t 192.168.10.11 80-r 192.168.11.12 VR 80-add back-end service IP

Ipvasdam-a-t 192.168.10.11 80-r 192.168.11.13 VR 80-add back-end service IP

Finally, change the virtual machine network editor vment8 z subnet ip to 192.168.10.0

Testing: win7 test

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report