How to set up the backend server gateway for EasySLB load balancing?
Published: 2015-01-19
Our company's load balancing EasySLB service uses NAT mode for traffic scheduling. This requires backend servers to return data packets to the load balancer. By default, data is returned directly to users over the public network,
so if it is not configured, SLB cannot work properly.
Normally, when you add a backend server to the cluster in the Load Balancing EasySLB console, the system automatically configures the backend server's route and gateway to ensure that the Load Balancing EasySLB service works properly,
but this is only supported by the new agent. If your backend server was provisioned earlier, the system cannot automatically configure the gateway and route for you, so you need to manually configure the gateway and route of the backend server.
This process is rather cumbersome. Another relatively simple method is to directly reinstall the backend server, after which it can be added automatically.
Before configuration, you need to first obtain the "load balancer private IP". It can be found in the "Load Balancing SLB" console. Here it is assumed to be "192.168.3.1"
The configuration method for a Windows backend server is as follows:
1. Log in to the server using Remote Desktop.
2. Right-click "My Network Places" - "Properties" to open Network Connections, as shown below.
3. Our company's cloud hosts usually have two connections, i.e. two network adapters: one public network adapter and one private network adapter. Both network adapters need to be configured. It is impossible to distinguish the private and public network adapters by name alone.
So now we first right-click the first connection. For example, here it is "Local Area Connection", select "Properties", then select "Internet Protocol (TCP/IP)", "Properties", as shown below.
An important thing here is to determine whether this network adapter is private or public. We find that the IP address is 192.* and the default gateway is empty, which indicates that this network adapter is a "private network" adapter, so two settings need to be configured.
3.1.1 Set the private network gateway
That is, set the "Default Gateway" to the previously obtained private IP of the load balancer; here it is assumed to be "192.168.3.1"
3.1.2 Set the private network adapter "Metric"
Click "Advanced..." in the figure above, click "Edit" under "Default Gateway", then clear the "Automatic metric" checkbox, and finally enter the value "5" in "Metric", then click OK. As shown below.
The above is the configuration of the private network adapter. In summary, there are actually only two points: the first is to configure the default gateway as the private IP of the load balancer; the second is to set the route metric
(actually route distance, or route hop count) to 5, giving it a higher priority.
4. Right-click the other network adapter, here it is "Local Area Connection 10", click "Properties" - "Internet Protocol (TCP/IP)", as shown below.
Based on the IP, we can determine that this network adapter is a public network adapter. For the public network adapter, only one parameter needs to be modified, namely "Metric". Change the value from "Automatic metric" to "3".
After the above configuration, the Windows backend server can be used.
The configuration method for a Linux backend server is as follows:
1. Log in to the Linux server using SSH.
2. Run the following 5 commands.
echo 200 slb>>/etc/iproute2/rt_tables
ip rule add from 192.168.225.153 table slb#where 192.168.225.153 must be replaced with the private IP of this machine
ip route add default via 192.168.3.1 dev eth1 table slb#where 192.168.3.1 is the private IP of the load balancer, and must be replaced with the correct IP
echo ip rule add from 192.168.225.153 table slb>>/etc/rc.local #where 192.168.225.153 must be replaced with the private IP of this machine
echo ip route add default via 192.168.3.1 dev eth1 table slb>>/etc/rc.local #where 192.168.3.1 is the private IP of the load balancer, and must be replaced with the correct IP
