Tutorials How to configure floating IP on Windows

How to configure floating IP on Windows

Once you get a confirmation from the UpCloud Support that a floating IP has been added, you should configure it on your server. You can find the floating IP attached to one of the servers at your UpCloud control panel, but using the added IP will require some manual setup. Follow the steps below to find out how to get this done on Windows servers.

Setting up static IP addresses

For this example, the server 1 (185.20.139.167) and the server 2 (185.20.139.162) have a common floating IP 185.20.139.29, netmask 255.255.252.0 and gateway 185.20.136.1.

First, you need to configure the servers at the OS level, so start up your systems and log in.

Windows servers need to set the network interface with the public IPv4 to static either through the network settings properties or by using netsh on the command prompt.

Next, check the network connection name. Open the Windows Command Prompt as administrator (cmd on run) and enter the following command.

netsh interface ip show config

Find the network adapter with your public IPv4 address. It is usually called just “Ethernet” like in the example output below.

Configuration for interface "Ethernet"
   DHCP enabled:                         Yes
   IP Address:                           185.20.139.167
   Subnet Prefix:                        185.20.136.0/22 (mask 255.255.252.0)
   Default Gateway:                      185.20.136.1
   Gateway Metric:                       0
   InterfaceMetric:                      5
   DNS servers configured through DHCP:  94.237.127.9
                                         94.237.40.9
   Register with which suffix:           Primary only
   WINS servers configured through DHCP: None

Then use the next command by giving the adapter name, IP address, netmask and gateway. This will set the interface to static configuration.

netsh interface ip set address "network_adapter" static public_IP subnet_mask gateway

For this example setup, on server 1 the command would be the following.

netsh interface ip set address "Ethernet" static 185.20.139.167 255.255.252.0 185.20.136.1

Your remote desktop connection might get interrupted for a few seconds while changes are being applied, but should reconnect shortly. In case you do loose connection and are unable to reconnect, you can always use the web console at UpCloud control panel under your server settings to go through the setup again to make sure everything is entered correctly.

After setting the IP address to static you will need to add at least one domain name server. Use the command below to add the DNS addresses as shown in the interface configuration output to the same network adapter as you set the static IP.

netsh interface ip add dns "Ethernet" 94.237.127.9
netsh interface ip add dns "Ethernet" 94.237.40.9 index=2

Repeat the steps on your other server to configure it with static IP and DNS addresses as well.

Configuring the floating IP

To enable the floating IP, you need to add it as an alias to the NIC with your public static IP. Start by checking which of your servers the floating IP is attached to. You will see the floating IP as an additional IP address under your Server settings and IP addresses at the UpCloud control panel. Configured the floating IP on that server as instructed below.

Windows has the option to add an alias IP address to your primary network connection through the advanced properties, but the simplest way is to use netsh on the command prompt. If you have multiple Windows systems you wish to use the floating IP on, only add it to one server at the time.

Open the Command Prompt again and use the command below while replacing the network adapter, floating IP and netmask with the information specific to your server.

netsh -c interface ip add address name="network_adapter" addr=floating_IP mask=netmask

In this example, the command would be the following.

netsh -c interface ip add address name="Ethernet" addr=185.20.139.29 mask=255.255.252.0

This also automatically enables the new alias IP allowing direct traffic to the server over your floating IP. You’ll only need to do this on the server that you want the floating IP to point to.

Now attempt to connect to your server through the floating IP with Remote Desktop Connection. Or if you have a web server configured, open the floating IP on your web browser.

When you get a reply, the floating IP works on that server and you can continue forward. If it didn’t work, make sure you entered the IP address and netmask correctly, that your firewall isn’t blocking your connections, or try another method to connect.

Testing the configuration

Your configuration is now complete. You can test that it works by transferring the floating IP from one server to another.

To do this, delete the floating IP on the currently attached server by entering the command below on Command Prompt. Replace the network adapter and floating IP with your values.

netsh -c interface ip delete address name="network_adapter" addr=floating_IP

Then create the alias again on the server 2 using the same command as before.

netsh -c interface ip add address name="network_adapter" addr=floating_IP mask=netmask

Test the floating IP again with any method you prefer. When you get a connection you have successfully transferred your floating IP.

Using your new floating IP

Moving the floating IP between Windows servers can be done by entering the netsh command to delete the alias on the currently connected server, and then adding alias again on the new target machine with the same netsh command as before.

Depending on your intended use case for the floating IP you may wish to continue by setting up automated load balancing. However, if you wish to manually transfer the traffic between your servers, it might be useful to create scripts of the required commands.

Leave a Reply

Your email address will not be published. Required fields are marked *

Locations

Helsinki (HQ)

In the capital city of Finland, you will find our headquarters, and our first data centre. This is where we handle most of our development and innovation.

London

London was our second office to open, and a important step in introducing UpCloud to the world. Here our amazing staff can help you with both sales and support, in addition to host tons of interesting meetups.

Seattle

Seattle is our 4th and latest office to be opened, and our way to reach out across the pond to our many users in the Americas.

Singapore

Singapore was our 3rd office to be opened, and enjoys one of most engaged and fastest growing user bases we have ever seen.