3.7. Turning on Packet Forwarding and Nonlocal Binding
In order for the Keepalived service to forward network packets properly to the real servers, each router node must have IP forwarding turned on in the kernel. Log in as
root
and change the line which reads net.ipv4.ip_forward = 0
in /etc/sysctl.conf
to the following:
net.ipv4.ip_forward = 1
The changes take effect when you reboot the system.
Load balancing in HAProxy and Keepalived at the same time also requires the ability to bind to an IP address that are nonlocal, meaning that it is not assigned to a device on the local system. This allows a running load balancer instance to bind to an IP that is not local for failover.
To enable, edit the line in
/etc/sysctl.conf
that reads net.ipv4.ip_nonlocal_bind
to the following:
net.ipv4.ip_nonlocal_bind = 1
The changes take effect when you reboot the system.
To check if IP forwarding is turned on, issue the following command as
root
:
/usr/sbin/sysctl net.ipv4.ip_forward
To check if nonlocal binding is turned on, issue the following command as
root
:
/usr/sbin/sysctl net.ipv4.ip_nonlocal_bind
If both the above commands return a
1
, then the respective settings are enabled.