Ping not working with IP Sharing
Im in the process of configuring load distribution using Nginx and implementing failover using IP sharing between the primary and secondary nodes with same data centre. Here are the specific configuration details:
- When primary linode experiences a complete outage, the secondary linode will handle all incoming traffic by IP sharing.
- Both the primary and secondary linode will host an application, and the primary node will distribute the load between them using an Nginx load balancer.
I could establish #1 failover mechanism without any issues, but not #2. Primary Linode is not able to ping/acces secondary Linode once I configure network configurations in netplan YAML file as mentioned in https://www.linode.com/docs/products/compute/compute-instances/guides/failover/
What do I need to do to make ip sharing/failover and ping work between primary and secondary node?
After reading through the documentation on configuring failover, I think there are a few things that can be clarified for anyone running into networking issues while setting this up. Those include making sure that you're using a static networking configuration, confirming that the shared IP is only configured on the lo interface and not the ETH0 interface, and understanding how various networking files work together.
I used Lelastic to test this on Ubuntu 22.04 because that seemed to the be distro that needed the most clarification, but some of this will help with others as well.
First, anyone deploying Linodes for this purpose should use Network Helper when first creating the instances, which requires it be turned on in the Global Account Settings. This may seem counterintuitive since the guide instructs you to turn it off as one of the steps. The reason for this is that if Network Helper is not used, the IP addresses will be assigned with DHCP, which is dynamic and may cause issues when adding the shared IP address to the primary node. You'll still want to turn off Network Helper (also called Auto-Configure Networking) on the instances when the guide suggests it, but deploying with it on globally will ensure your Linode has static networking configured.
If you can't remember if you're using static or dynamic networking, you can use the command
ip r to find out. Your output should mention the word
dhcp to let you know how the system is configured.
Shared IP Interface
Next, in the section of the failover guide called Create and Share the Shared IP Address, you'll see you'll have the option to add a second public IPv4 to your Compute Instance to use as the shared IP. You may need to open a ticket with our Support Team to request the ability to add a second IPv4.
You'll want to make sure that the IP that will be used for sharing is not configured on the ETH0 interface of the Primary server before configuring that IP for sharing. There is a note about this, but I think that it can be confusing depending on what distribution you're using and how different files work together, which may not be clear based on that guide alone.
Our guide explains how to configure IP Sharing using Netplan for Ubuntu 18.04 or newer and explains how to configure the file
/etc/netplan/01-netcfg.yaml. The issue with this is that Netplan doesn't contain the configurations for ETH0, which can be found in the file
etc/systemd/network/05-eth0.network. You'll want to make sure that file doesn't list the shared IP under ETH0. If it does, you'll need to remove it and make sure the gateway is correct for the non-shared IP. The reason for this is that the shared IP could end up on the same subnet and gateway as the secondary nodes IP, which can lead to communication issues, including an inability to ping from the primary to the secondary Linode.
To see where your network configurations live on an instance that was created with Network Helper, you can find that information by distro in our guide under the section Files Maintained by Network Helper.
In this use case, Netplan serves as a frontend for configuring systemd-networkd, so both files are working together. To understand how the system prioritizes files, you can look at the number in the file. The lower the number, the higher the priority. While the Netplan
.yaml file has a priority of
etc/systemd/network/05-eth0.network has a priority of
05, after investigating, I found that
.yaml file creates a file here with a lower priority:
This means that whatever you have configured in
etc/systemd/network/05-eth0.network will be priotized, so you don't have to worry about what the ETH0 configuration says in Netplan if you've correctly configured it in the systemd file. In the example file provided by the Failover guide, you can see that DHCP is still enabled in Netplan:
However, if the systemd file has a lower number attached and therefore a higher priority, your system will use the static IP listed there for ETH0 and not use dhcp, regardless of what it says in the Netplan file. If you find your system is using DHCP despite it being turned off in the systemd file, you may want to check to see if the files above have the correct priority.