Updating your Dedicated Linux server IP address to your new IP details.

Updating your Dedicated Linux server IP address to your new IP details.

This article applies to Linux Dedicated Servers.

If you want to replace your current IP addresses with new IP addresses that have been allocated to you, please follow the steps below:

  • Add the IP addresses to your network interface
  • Configure the DNS to work with the new IP addresses
  • Update Apache to listen and serve pages from the new IP addresses
  • List of default gateways based on primary IP network

These main four steps are broken up as follows:

Adding the new IP addresses to your network interface

1

Edit the file:

/etc/network/interfaces

which configures all the IP addresses your server responds to. There are sections for each of your existing IP addresses that are usually divided by blank lines. Each IP address has an interface name associated with it. One IP address will be your server's primary IP address; this will have an interface name that doesn't have a colon in it, probably:

eth0

2

Each of the other IP addresses has an interface name – the primary interface’s name – followed by a colon and another number (eg eth0:0 or eth0:1). There will also be a section labelled lo, which is the section for the loopback interface. You will not need to make any changes to it, so please leave it as it is.

3

Both your old and new IP addresses need to work for a transitional period, which means we now need to add additional sections for your new IP addresses while we are also keeping the old ones in place.

4

To start with, you will need to create a section for a new primary interface. To do this, simply copy all the existing lines that define the existing primary interface. These should include a gateway line, and possibly a pre-up line too. Now change the IP address and gateway in the new primary interface to the equivalent new addresses. Once you’ve done that, delete any gateway and pre-up lines in the old primary interface, while leaving the IP address defines. This will allow both the old and new IP addresses to work over the transition period.

5

Keep in mind that for each additional IP address you have to create a new section. Also, in each case you will need to copy the entire section from the previous IP and then change the IP address to the new one.

6

The sections also need to be renumbered in order to make the numbering consistent. Your new primary IP address will need to be the interface name without the colon-number suffix, such as eth0. The other interfaces, such as the old primary interface, will need to have a unique colon-number, starting from: 0 and working up without any gaps:

eth0:0

eth0:1

eth0:2

and so on.

For example:

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 109.104.77.000
netmask 255.255.254.0
gateway 109.104.77.254
pre-up /usr/sbin/ethtool -s eth0 speed 10 duplex full autoneg off

auto eth0:1
iface eth0:1 inet static
address 62.44.83.163
netmask 255.255.254.0

auto eth0:0
iface eth0:0 inet static
address 109.104.77.000
netmask 255.255.254.0

auto eth0:2
iface eth0:2 inet static
address 62.44.83.000
netmask 255.255.254.0

7

Before you save the file, please check to ensure that you have one primary interface definition eth0. This is the new IP address and it will have a new gateway. Also, check to see that each of the other IP addresses (old and new) has their own definition, that the gateway line has been deleted from the old primary IP address and that each of the interfaces has a unique number.

8

Save the file, then run this command to restart your network, using the new IP addresses:

/etc/init.d/network/restart

Configure the DNS to work with the new IP addresses

1

Edit the file:

/usr/local/djbdns/service/tinydns/env/IP

and remove all its existing content, replacing it with the single line:

0.0.0.0

2

Do the same for the file:

/usr/local/djbdns/service/axfrdns/env/IP

3

Save both files, and run these commands:

svc -d /service/tinydns ; svc -u /service/tinydns

svc -d /service/axfrdns ; svc -u /service/axfrdns

Update Apache to listen and serve pages from the new IP addresses

1

Update the old IP address everywhere in your Apache config where it is mentioned and replace it to mention both the old and new IP addresses. The procedure depends on how you have configured Apache.

2

If you are running a chroot set-up, you probably have two separate Apache instances that you will need to update. In the default installation there was an Apache instance running the control panel, configured by the files in the:

/etc/apache-ssl/

directory, and an Apache instance for your websites, configured by:

/usr/fs/etc/apache2/

3

IP addresses can be mentioned in two forms: Listen directives, and VirtualHost directives.

4

Duplicate each line that stats with Listen followed by an IP address to ensure there are two identical Listen directives on adjacent lines. Now change the IP address on one of them to the new IP address. Ensure that after the IP address you have a colon and then a port number (a single integer, probably :80 or :443); do not change this so it is the same for both the current and new IP addresses.

5

There may also be some Listen directives which just mention a port number and no IP address. If so, do not change these either.

6

For each line starting with VirtualHost followed by an IP address and a port number, add a space after the IP address and then add the new IP address followed by a colon and the same port number as the old IP address. If you find that the line has multiple IP addresses, then add a new IP address for each one and separate them with spaces. The line can be as long as needed, but do check to ensure that there is no line-break character splitting the directive into multiple lines. The end of the line, after all the IP addresses, must be a single >" character.

7

There may also be some Listen directives which don't mention any IP address. If so, do not change them.

8

In the default config, you will need to edit these files:

/etc/apache-ssl/httpd.conf -- both Listen and VirtualHost

/usr/fs/etc/apache2/sites-available/default -- VirtualHost

/usr/fs/etc/apache2/ports.conf -- Listen

9

Restart each Apache instance. The non-chroot Apache can be restarted with this command:

/etc/init.d/apache-ssl stop

/etc/init.d/apache-ssl start

10

The chroot Apache is restarted with this command:

chroot /usr/fs /etc/init.d/apache2 stop

chroot /usr/fs /etc/init.d/apache2 start

New Range New Gateway
109.104.74.1/23 109.104.74.254
212.67.213.1/24 212.67.213.254
109.104.76.1/23 109.104.76.254
94.136.48.1/24 94.136.48.254
212.67.208.1/24 212.67.208.254
212.67.192.1/24 212.67.192.254
212.67.193.1/24 212.67.193.254
212.67.198.1/23 212.67.199.254
212.67.200.1/23 212.67.201.254
212.67.206.1/23 212.67.207.254
109.104.72.1/23 109.104.73.254
212.67.194.1/23 212.67.195.254
212.67.196.1/23 212.67.197.254