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.

As an example of a public floating IP, 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. These are highlighted below in red.

In case you wish to configure a private floating IP, see the example with server 1 (10.2.9.231), server 2 (10.2.10.25), private floating IP 10.2.9.108, netmask 255.255.252.0 and gateway 10.2.8.1. Follow the instructions underneath highlighted in purple.

Setting up static IP address

Firstly, you’ll need to configure the servers at the OS level, so start up your servers at your UpCloud control panel and log in.

Windows servers need to set a network interface for the floating IP to static either through the network settings properties or by using netsh on the command prompt. For public floating IPs, the right interface for this is the primary public IPv4 adapter, often named simply Ethernet. In contrary, a private floating IP is configured to the private IPv4 interface, usually Ethernet 2.

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

If you are configuring a public floating IP, find the network adapter with your public IPv4 address. It is usually called “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

Alternatively, if you are setting up a private floating IP, find the interface with your private IPv4 address. Generally, this is the second adapter called “Ethernet 2“.

Configuration for interface "Ethernet 2"
    DHCP enabled:                         Yes
    IP Address:                           10.2.9.231
    Subnet Prefix:                        10.2.8.0/22 (mask 255.255.252.0)
    InterfaceMetric:                      15
    DNS servers configured through DHCP:  None
    Register with which suffix:           Primary only
    WINS servers configured through DHCP: None

Once you’ve identified the right network interface and found your IP information, use the next command by giving the network_adapter, ip_address, netmask and gateway. This will set the interface to static configuration.

netsh interface ip set address "network_adapter" static ip_address netmask gateway

For this public floating IP 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

In case of a private floating IP, use the same command but with the private IPv4 addresses, for example as follows. The gateway address doesn’t show in the interface configuration output but it is the first address in the subnet 10.2.8.0 -> 10.2.8.1 in this case.

netsh interface ip set address "Ethernet" static 10.2.9.231 255.255.252.0 10.2.8.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 a public 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 you wish to use the floating IP on to configure them 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 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  Networks tab 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.

On the server that the floating IP is attached to, Windows has likely created a new network interface that is reserving the address. Check the list of network adapters and find the interface with the floating IP. Make note of the name of the interface and disable it with the following command on the Command Prompt. This only applies to the first server.

netsh interface set interface "network_adapter" disable

Next, 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

For example with a public floating IP, the command would be the following.

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

On the other hand with a private floating IP, you would need to enter something like this.

netsh -c interface ip add address name="Ethernet 2" addr=10.2.9.231 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. Note that private floating IPs are only reachable from another cloud server on your UpCloud account.

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. This work the same regardless of whether you are transferring a public or private floating IP. 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 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.

Note that the Windows Firewall blocks both inbound and outbound ICMP requests used by ping, allow these if you wish to test the floating IP with ping.

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.