{"id":2509,"date":"2015-02-19T12:44:06","date_gmt":"2015-02-19T10:44:06","guid":{"rendered":"https:\/\/upcloud.com\/global\/us\/resources\/tutorials\/attaching-new-ip-addresses\/"},"modified":"2015-02-19T12:44:06","modified_gmt":"2015-02-19T10:44:06","slug":"attaching-new-ip-addresses","status":"publish","type":"tutorial","link":"https:\/\/upcloud.com\/global\/resources\/tutorials\/attaching-new-ip-addresses\/","title":{"rendered":"Attaching new IP addresses"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">It is possible to have up to five public IPv4 and IPv6 addresses per your UpCloud server.&nbsp; You\u2019ll need to shut down your cloud server before making changes to the network interfaces. Afterwards, you can&nbsp;attach new IP addresses by logging into your&nbsp;<a rel=\"noopener\" href=\"https:\/\/hub.upcloud.com\" target=\"_blank\">UpCloud Control Panel<\/a>&nbsp;and going to your server settings and <em>Network<\/em>&nbsp;tab.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/signup.upcloud.com\/\">Test hosting on UpCloud!<\/a><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Attaching new addresses<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">While the server is powered down, add a new IP address by selecting the type of address you want, public IPv4 or IPv6, and clicking the <em>Attach address<\/em> button.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/server-network-1.png\" alt=\"Server network details\" class=\"wp-image-5845\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">You\u2019ll get a confirmation notification and the new address will then appear on the list.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/cloning-server-4.png\" alt=\"New public IPv4 added\" class=\"wp-image-5949\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s how easy it is to attach new&nbsp;IP addresses on UpCloud Control Panel. However, there are some operations that must be done at the OS level in order for the system&nbsp;to become aware of the changes. Check below for the operating system-specific instructions for your server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Ubuntu 22 and later<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Connect to your Cloud Server. Once in, you\u2019ll need to add a new interface configuration. Since the release of Ubuntu 22, the OS has been using netplan which changes how the network interfaces are configured.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First, check the new network interface name with the command below. The new interface will be the last on the list without an IP, <tt>eth3<\/tt> in the example below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">ip addr<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">5: <span style=\"color:red;\">eth3<\/span>: &lt;BROADCAST,MULTICAST&gt; mtu 1500 qdisc noop state DOWN group default qlen 1000\n    link\/ether 6e:d7:1b:bf:3b:cf brd ff:ff:ff:ff:ff:ff\n    altname enp0s5\n    altname ens5<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next, create a new network configuration file and add the following content. Make sure you name the interface correctly.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo nano \/etc\/netplan\/60-eth3.yaml<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">network:\n    version: 2\n    renderer: networkd\n    ethernets:\n        <span style=\"color:red;\">eth3<\/span>:\n            dhcp4: true<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are adding an IPv6, the syntax is a little different, use the following instead.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">network:\n    version: 2\n    renderer: networkd\n    ethernets:\n        <span style=\"color:red;\">eth3<\/span>:\n            dhcp6: true<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then save the file and exit the editor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Lastly, apply the changes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo netplan apply<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the changes were applied successfully, you should now be able to see the new IP address.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">ip addr show dev <span style=\"color:red;\">eth3<\/span><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">5: eth3: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc fq_codel state UP group default qlen 1000\n    link\/ether 6e:d7:1b:bf:3b:cf brd ff:ff:ff:ff:ff:ff\n    altname enp0s5\n    altname ens5\n    inet 94.237.59.222\/22 metric 100 brd 94.237.59.255 scope global dynamic eth2\n       valid_lft 86396sec preferred_lft 86396sec\n    inet6 fe80::6cd7:1bff:febf:3bcf\/64 scope link \n       valid_lft forever preferred_lft forever<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once you see the new interface at the end of the list like in the example above you\u2019ve successfully configured a new IP address to your Cloud Server. It can now be used to connect to the host just like the other addresses.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Debian and Ubuntu 20 or earlier<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Connect to your Cloud Server. Once in, you\u2019ll need to add a new interface configuration to the <tt>\/etc\/network\/interfaces<\/tt>&nbsp;file. Open it for editing with elevated privileges.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo nano \/etc\/network\/interfaces<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then enter one of the examples underneath the end of the file. The number of the network interface needs to be unique, set it to one larger than the previous one. If you haven\u2019t added addresses before it should be <em>eth3<\/em> like in the example here.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">auto eth3\niface eth3 inet dhcp<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the case of IPv6 the syntax is a little different, use the following instead.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">auto eth3\niface eth3 inet6 auto<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then save the file and exit the editor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Afterwards, you\u2019ll need to restart the network to have the changes take effect.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo systemctl restart networking<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check that the new interface appears and shows the correct new IP address with the following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">ip addr<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the IP addresses are not working after this, add the following lines to <tt>\/etc\/sysctl.conf<\/tt>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo nano \/etc\/sysctl.conf<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">net.ipv4.conf.all.rp_filter=0\nnet.ipv4.conf.default.rp_filter=0\nnet.ipv4.ip_forward = 1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On Ubuntu, you might also need to add the following to the specific new network interface and replace the number on the lines as appropriate.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">net.ipv4.conf.<span style=\"color: #ff0000;\">eth3<\/span>.rp_filter = 2\nnet.ipv4.conf.<span style=\"color: #ff0000;\">eth3<\/span>.arp_filter = 1<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once you\u2019ve saved the <tt>sysctl.conf<\/tt>, update the system status.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo sysctl -p<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then restart the network using the same command as above and check the IP addresses again.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo systemctl restart networking<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">ip addr<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">5: eth3: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP group default qlen 1000\n    link\/ether 6e:d7:1b:bf:63:c8 brd ff:ff:ff:ff:ff:ff\n    inet 185.26.50.223\/22 brd 185.26.51.255 scope global eth3\n       valid_lft forever preferred_lft forever\n    inet6 fe80::6cd7:1bff:febf:63c8\/64 scope link\n       valid_lft forever preferred_lft forever<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once you see the new interface at the end of the list like in the example above you\u2019ve successfully configured a new IP address to your Cloud Server. It can now be used to connect to the host just like the other addresses.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you have problems reaching one of the IP addresses with <tt>ping<\/tt>, for example, try rebooting the server and testing the connection again.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo reboot<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Also, make sure your firewall settings allow connecting to the new IP address as well.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">CentOS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You\u2019ll need to create a new network interface configuration file in the&nbsp;<tt>\/etc\/sysconfig\/network-scripts<\/tt>&nbsp;folder. Copy one of the pre-existing files to have a starting point, for example, the&nbsp;<tt>ifcfg-<span style=\"color: #ff0000;\">eth0<\/span><\/tt> to <tt>ifcfg-<span style=\"color: #ff0000;\">eth3<\/span><\/tt>&nbsp;with the following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo cp \/etc\/sysconfig\/network-scripts\/ifcfg-<span style=\"color: #ff0000;\">eth0<\/span> \/etc\/sysconfig\/network-scripts\/ifcfg-<span style=\"color: #ff0000;\">eth3<\/span><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then open the new file and change it to suit the new interface. Replace the device number on the first line with a new higher number. Commonly it would be <tt>eth3<\/tt> like in the example below if this is the first address you are adding after deploying the cloud server.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">DEVICE=eth3\nBOOTPROTO=dhcp\nONBOOT=yes<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are attaching an IPv6 address, you can copy the existing IPv6 configuration.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo cp \/etc\/sysconfig\/network-scripts\/ifcfg-<span style=\"color: #ff0000;\">eth2<\/span> \/etc\/sysconfig\/network-scripts\/ifcfg-<span style=\"color: #ff0000;\">eth3<\/span><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then change the device name, for example as below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">DEVICE=eth3\nNM_CONTROLLED=no\nIPV6INIT=yes<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check your <tt>\/etc\/sysctl.conf<\/tt>, and make sure the default <tt>rp_filter<\/tt> is set to 0.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo sysctl -a | grep default.rp_filter<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If not, open the file to edit and add the parameter to the end of the file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">net.ipv4.conf.default.rp_filter = 0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you made changes to the <tt>sysctl.conf<\/tt>, update the system.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo sysctl -p<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use the following command after you have done these operations to restart the network.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo systemctl restart network<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then check the IP configuration.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">ip addr<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">5: eth3: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000\n    link\/ether 6e:d7:1b:bf:49:64 brd ff:ff:ff:ff:ff:ff\n    inet 185.20.138.90\/22 brd 185.20.139.255 scope global dynamic eth3\n       valid_lft 86189sec preferred_lft 86189sec\n    inet6 fe80::6cd7:1bff:febf:4964\/64 scope link\n       valid_lft forever preferred_lft forever<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When you see the new IP address in the command output it\u2019s connected and ready to use.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you have problems reaching one of the IP addresses with <tt>ping<\/tt>, for example, try rebooting the server and testing the connection again.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo reboot<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Also, make sure your firewall settings allow connecting to the new IP address as well.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Windows<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">New network interfaces for IPv4 addresses should show up automatically without manual configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the case of IPv6, you&nbsp;will need to run a couple of commands via <em>Command Prompt<\/em> with Administrator privilege. Open the program by typing <em>cmd<\/em> in the Run window and press enter, then copy in the commands below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">netsh interface ipv6 set global randomizeidentifiers=disabled store=active \nnetsh interface ipv6 set global randomizeidentifiers=disabled store=persistent \nnetsh interface ipv6 set privacy state=disabled store=active \nnetsh interface ipv6 set privacy state=disabled store=persistent<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Afterwards, you should restart the new network interface by disabling and re-enabling it at the Network Connections window.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note that the Windows Server firewall blocks ICMP requests by default. If you want to test the new interface with ping, open the firewall settings with <tt>wf.msc<\/tt> in the run window. Find the ICMPv4 and ICMPv6 protocols in the Inbound Rules and enable the ones you need.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Other options<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It\u2019s also possible to manually set additional public IPv4 addresses to the primary interface, for example creating aliases like eth0:1, and eth0:2 on Linux, by using static configuration. Currently, this is not supported with IPv6 addresses. You can find instructions for setting up alias addresses in our articles for configuring floating IPs on&nbsp;<a href=\"https:\/\/upcloud.com\/global\/resources\/tutorials\/configure-floating-ip-centos\">CentOS<\/a>, <a href=\"https:\/\/upcloud.com\/global\/resources\/tutorials\/configure-floating-ip-debian\">Debian<\/a>, <a href=\"https:\/\/upcloud.com\/global\/resources\/tutorials\/configure-floating-ip-ubuntu\">Ubuntu<\/a>&nbsp;or&nbsp;<a href=\"https:\/\/upcloud.com\/global\/resources\/tutorials\/configure-floating-ip-windows\">Windows<\/a>.<\/p>\n","protected":false},"author":3,"featured_media":27207,"comment_status":"open","ping_status":"closed","template":"","community-category":[259,283,247],"class_list":["post-2509","tutorial","type-tutorial","status-publish","has-post-thumbnail","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial"}],"about":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/types\/tutorial"}],"author":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/comments?post=2509"}],"version-history":[{"count":0,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2509\/revisions"}],"wp:attachment":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/media?parent=2509"}],"wp:term":[{"taxonomy":"community-category","embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/community-category?post=2509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}