In multiple test and prod environments we often come across scenarios where there is a need to access multiple applications exposed on different Ip’s.
These App’s may be running on either a single machine or on different machines and we need one single endpoint for them.
In an ideal scenario we will use a load balancer. However, in a lab environment or in small environments where hosting a LB is just not efficient, we can apply a small tweak or feature which allows us to give multiple IP Addresses to a single NIC.
This method is very handy when working with containers.
Let’s assume that we are using Open SUSE as OS which has HAProxy installed and wicked as a Network Manager.
1. Check IP address in HAProxy server:
#ip a
2. Edit the eth0 config file within the network config directory and add the virtual ip’s.
#vim /etc/sysconfig/network/ifcfg-eth0
As you can see I have added 4 virtual IP’s in the config file.
3. Make changes in the file as above and reload the network service.
#wicked ifreload eth0
Do not add additional gateways or it will bring down the entire network when starting. 😀
4. Check if the IP’s are showing:
#ip a
Now you can use 1 IP each for one service and an HAProxy server can serve as frontend and forward the incoming connections to respective backends.
Hope you liked this post see you in another one of blog.avoidingtech.com.