Difference between revisions of "Changing, Adding, and Removing IP Addresses"
m |
|||
Line 1: | Line 1: | ||
{| border="0" cellpadding="5" cellspacing="2" style="border:1px solid #6c6; background-color:#FFFFFF; border-left:10px solid #3c3; margin-bottom:0.4em; margin-left:auto; margin-right:auto; width:100%" | {| border="0" cellpadding="5" cellspacing="2" style="border:1px solid #6c6; background-color:#FFFFFF; border-left:10px solid #3c3; margin-bottom:0.4em; margin-left:auto; margin-right:auto; width:100%" | ||
− | |- | + | |- |
− | | style="font-size: 95%; text-align:left" | | + | | style="font-size: 95%; text-align:left" | |
Unfamiliar with IPv6? Try Hurricane Electric's free [http://ipv6.he.net/certification/ IPv6 certification]. | Unfamiliar with IPv6? Try Hurricane Electric's free [http://ipv6.he.net/certification/ IPv6 certification]. | ||
|} | |} | ||
Line 8: | Line 8: | ||
You may have received an email telling you of a change to your IP addresses. The email tells you how to replace your old IP addresses with the new ones. This wiki page expands on that procedure and adds a few more for adding and removing addresses. If you have not received an email about your IP addresses then this procedure does not apply to you. | You may have received an email telling you of a change to your IP addresses. The email tells you how to replace your old IP addresses with the new ones. This wiki page expands on that procedure and adds a few more for adding and removing addresses. If you have not received an email about your IP addresses then this procedure does not apply to you. | ||
− | If you have two addresses, then you have a choice: you can change your old IP address to the new address, or you can add the new address and run both at once. See below for some pros and cons of each | + | If you have two addresses, then you have a choice: you can change your old IP address to the new address, or you can add the new address and run both at once. See below for some pros and cons of each. |
− | |||
− | |||
+ | If you have received an email from us about replacing or adding an IP address, then refer there for your old and new addresses. Your email comes with several attachments (two scripts and a number of configuration files) that may simplify the process. | ||
== Change Your IP Address or Add One? Pros and Cons == | == Change Your IP Address or Add One? Pros and Cons == | ||
Line 21: | Line 20: | ||
It is possible to add the new IP addresses and then remove the old ones. This is the most complex of the three options, but it avoids present downtime and future problems with the original IP addresses. | It is possible to add the new IP addresses and then remove the old ones. This is the most complex of the three options, but it avoids present downtime and future problems with the original IP addresses. | ||
+ | |||
+ | == Using the Sample Files == | ||
+ | The email with your new IP addresses came with several attachments. You will [[use the scripts|#Using the IP Scripts]] only for [[#Adding a New IP Address]]. They are intended as a convenience to allow you to bring down your interfaces at a convenient time. You may use the attached configuration files to cut and paste when editing your IP configuration files in the following procedures. | ||
== Replacing Your IP Address == | == Replacing Your IP Address == | ||
Line 38: | Line 40: | ||
When your editor opens, you will see a file like this one: | When your editor opens, you will see a file like this one: | ||
<pre> | <pre> | ||
− | auto lo | + | # The loopback network interface |
− | iface lo inet loopback | + | auto lo |
+ | iface lo inet loopback | ||
+ | |||
+ | # The primary network interface | ||
+ | auto eth0 | ||
+ | iface eth0 inet static | ||
+ | address OLDIPV4ADDRESS | ||
+ | netmask 255.255.255.0 | ||
+ | gateway 64.62.188.1 | ||
+ | dns-nameservers 71.19.155.120 71.19.145.215 8.8.8.8 | ||
− | + | iface eth0 inet6 static | |
− | + | address OLDIPV6ADDRESS | |
− | iface eth0 | + | netmask 64 |
− | + | gateway 2001:470:1:41::1 | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
The addresses under ''iface eth0 inet static'' and ''iface eth0 inet6 static'' are your original IPv4 and IPv6 addresses, respectively. Edit the file to replace the IPv4 and IPv6 addresses with the new ones from your email, and make changes to the network, gateway, and DNS nameservers so the file looks like this: | The addresses under ''iface eth0 inet static'' and ''iface eth0 inet6 static'' are your original IPv4 and IPv6 addresses, respectively. Edit the file to replace the IPv4 and IPv6 addresses with the new ones from your email, and make changes to the network, gateway, and DNS nameservers so the file looks like this: | ||
<pre> | <pre> | ||
− | + | auto lo eth0 | |
− | auto lo eth0 | + | iface lo inet loopback |
− | iface lo inet loopback | ||
− | + | iface eth0 inet static | |
− | iface eth0 inet static | + | address NEWIPV4ADDRESS |
− | + | network 71.19.155.0 | |
− | + | netmask 255.255.255.0 | |
− | + | gateway 71.19.155.1 | |
− | + | dns-nameservers 71.19.155.120 71.19.145.215 8.8.8.8 | |
− | + | iface eth0 inet6 static | |
− | iface eth0 inet6 static | + | address NEWIPV6ADDRESS |
− | + | netmask 64 | |
− | + | gateway 2605:2700:0:17::1 | |
− | |||
</pre> | </pre> | ||
− | Save the file, exit the editor, then | + | Save the file, exit the editor, then flush the interfaces. |
+ | <pre> | ||
+ | $ /sbin/ip addr flush dev eth0 | ||
+ | </pre> | ||
+ | |||
+ | Enable the changes you've made by bringing the interface down, then bringing it up again. | ||
'''Important:''' If you are connected directly via SSH, you won't be able to send any more commands after bringing down the interface, so make sure you bring the interface back up in the same command: | '''Important:''' If you are connected directly via SSH, you won't be able to send any more commands after bringing down the interface, so make sure you bring the interface back up in the same command: | ||
Line 84: | Line 89: | ||
</pre> | </pre> | ||
− | Verify the changes to your IP addresses | + | ==== Verify the changes to your IP addresses ==== |
<pre> | <pre> | ||
$ ip addr show | $ ip addr show | ||
− | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default | + | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default |
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | ||
inet 127.0.0.1/8 scope host lo | inet 127.0.0.1/8 scope host lo | ||
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 ::1/128 scope host | + | inet6 ::1/128 scope host |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc | + | 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 |
link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff | link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff | ||
− | inet | + | inet NEWIPV4ADDRESS/24 brd 71.19.155.255 scope global eth0 |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 | + | inet6 NEWIPV6ADDRESS/64 scope global |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 | + | inet6 fe80::a800:ff:fe13:9b7a/64 scope link |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
</pre> | </pre> | ||
Line 117: | Line 122: | ||
When your editor opens, you will see a file like this one: | When your editor opens, you will see a file like this one: | ||
− | <pre> | + | <pre> |
DEVICE=eth0 | DEVICE=eth0 | ||
− | IPADDR= | + | IPADDR=OLDIPV4ADDRESS |
NETMASK=255.255.255.0 | NETMASK=255.255.255.0 | ||
− | GATEWAY= | + | GATEWAY=64.62.188.1 |
NM_CONTROLLED=no | NM_CONTROLLED=no | ||
ONBOOT=yes | ONBOOT=yes | ||
− | DNS1= | + | DNS1=71.19.155.120 |
− | DNS2= | + | DNS2=71.19.145.215 |
SEARCH=xen.prgmr.com | SEARCH=xen.prgmr.com | ||
TYPE=Ethernet | TYPE=Ethernet | ||
Line 133: | Line 138: | ||
IPV6INIT=yes | IPV6INIT=yes | ||
− | IPV6ADDR= | + | IPV6ADDR=OLDIPV6ADDRESS/64 |
− | IPV6_DEFAULTGW=2001: | + | IPV6_DEFAULTGW=2001:470:1:41::1 |
</pre> | </pre> | ||
− | The addresses under ''IPADDR'' and ''IPV6ADDR'' are your original IPv4 and IPv6 addresses, respectively. Edit the file to | + | The addresses under ''IPADDR'' and ''IPV6ADDR'' are your original IPv4 and IPv6 addresses, respectively. Edit the file to look like this: |
<pre> | <pre> | ||
− | DEVICE=eth0 | + | DEVICE=eth0 |
− | + | BOOTPROTO=none | |
− | + | ONBOOT=yes | |
− | IPADDR= | + | TYPE=Ethernet |
− | NETMASK=255.255.255.0 | + | IPADDR=NEWIPV4ADDRESS |
− | GATEWAY= | + | NETMASK=255.255.255.0 |
− | + | GATEWAY=71.19.155.1 | |
− | + | IPV6INIT=yes | |
− | + | IPV6ADDR="NEWIPV6ADDRESS/64" | |
− | + | IPV6AUTOCONF=no | |
− | + | IPV6_DEFAULTGW=2605:2700:0:17::1 | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | IPV6INIT=yes | ||
− | IPV6ADDR=" | ||
− | IPV6_DEFAULTGW=2605: | ||
</pre> | </pre> | ||
Line 173: | Line 168: | ||
</pre> | </pre> | ||
− | Verify the new IP addresses: | + | Verify the new IP addresses: |
<pre> | <pre> | ||
$ ip addr show | $ ip addr show | ||
− | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN | + | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN |
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | ||
inet 127.0.0.1/8 scope host lo | inet 127.0.0.1/8 scope host lo | ||
− | inet6 ::1/128 scope host | + | inet6 ::1/128 scope host |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 | 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 | ||
link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff | link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff | ||
− | inet | + | inet NEWIPV4ADDRESS/24 brd 17.91.151.255 scope global eth0 |
− | inet6 | + | inet6 NEWIPV6ADDRESS/64 scope global |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 | + | inet6 fe80::a800:ff:fe13:9b7a/64 scope link |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
</pre> | </pre> | ||
Line 194: | Line 189: | ||
== Adding a New IP Address == | == Adding a New IP Address == | ||
To add an IP address in Debian derivatives (we provide Debian and Ubuntu images) you will edit a file. For Red Hat derivatives (CentOS and Fedora) you will add a new file. For other distros, check your user documentation. | To add an IP address in Debian derivatives (we provide Debian and Ubuntu images) you will edit a file. For Red Hat derivatives (CentOS and Fedora) you will add a new file. For other distros, check your user documentation. | ||
+ | |||
+ | === Using the IP Scripts === | ||
+ | If you received an email notifying you of your new IP addresses, then you also received two scripts. You can use these scripts to make a temporary change to your IP addresses without bringing your interface down. | ||
+ | |||
+ | '''Important:''' The scripts you received make a temporary change to the state of your system - implementing the new IP addresses with no need to bring the interface down and then up again. However these changes are not reflected in your IP configuration files. You must still update your configuration files with the new IP addresses before your reboot your system (either deliberately or otherwise). If you do not then the system will revert to its original state after reboot. | ||
+ | |||
+ | ==== Transferring the Scripts ==== | ||
+ | If you have transferred files before between your local system and your VPS then use your favorite method. If not then run the following command on your local system, inserting the file names as needed. This command will copy the scripts to the /home directory of your VPS. | ||
+ | <pre> | ||
+ | scp -i ~/.ssh/SSH_KEY [LOCAL_FILE_PATH] [USERNAME]@[USERNAME].xen.prgmr.com: | ||
+ | </pre> | ||
+ | If your local OS is not Linux, or if this command fails for any reason, then you can open the scripts in a local text editor and paste them into nano on your VPS. Save the nano files to your preferred directory for running scripts. | ||
+ | |||
+ | ==== Running the Scripts ==== | ||
+ | First, you will add your new IP addresses. | ||
+ | <pre> | ||
+ | ./add-new-ips | ||
+ | </pre> | ||
+ | |||
+ | Verify the changes. | ||
+ | <pre> | ||
+ | ip addr show | ||
+ | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default | ||
+ | link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | ||
+ | inet 127.0.0.1/8 scope host lo | ||
+ | valid_lft forever preferred_lft forever | ||
+ | inet6 ::1/128 scope host | ||
+ | valid_lft forever preferred_lft forever | ||
+ | 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 | ||
+ | link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff | ||
+ | inet OLDIPV4ADDRESS/24 brd 64.62.188.255 scope global eth0 | ||
+ | valid_lft forever preferred_lft forever | ||
+ | inet NEWIPV4ADDRESS/24 scope global eth0 | ||
+ | valid_lft forever preferred_lft forever | ||
+ | inet6 NEWIPV6ADDRESS/64 scope global | ||
+ | valid_lft forever preferred_lft forever | ||
+ | inet6 OLDIPV6ADDRESS/64 scope global | ||
+ | valid_lft forever preferred_lft forever | ||
+ | inet6 fe80::a800:ff:fe13:9b7a/64 scope link | ||
+ | valid_lft forever preferred_lft forever | ||
+ | </pre> | ||
+ | |||
+ | Go to [[#Testing your connection]]. | ||
+ | |||
+ | Whenever you are ready to transfer completely to the new IP addresses, run your remove script. | ||
+ | <pre> | ||
+ | ./rm-old-ips | ||
+ | </pre> | ||
+ | |||
+ | And again, verify the changes. | ||
+ | <pre> | ||
+ | ip addr show | ||
+ | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default | ||
+ | link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | ||
+ | inet 127.0.0.1/8 scope host lo | ||
+ | valid_lft forever preferred_lft forever | ||
+ | inet6 ::1/128 scope host | ||
+ | valid_lft forever preferred_lft forever | ||
+ | 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 | ||
+ | link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff | ||
+ | inet NEWIPV4ADDRESS/24 brd 71.19.155.255 scope global eth0 | ||
+ | valid_lft forever preferred_lft forever | ||
+ | inet6 NEWIPV6ADDRESS/64 scope global | ||
+ | valid_lft forever preferred_lft forever | ||
+ | inet6 fe80::a800:ff:fe13:9b7a/64 scope link | ||
+ | valid_lft forever preferred_lft forever | ||
+ | </pre> | ||
+ | |||
+ | Remember that you must update your configuration files as outlined below before rebooting your system. | ||
=== Adding a new IP address in Debian/Ubuntu === | === Adding a new IP address in Debian/Ubuntu === | ||
− | The procedure is very similar to replacing the IP address, as outlined above. The main difference is that you will add new address entries to /etc/network/interfaces rather than editing the existing entries. This requires some other changes to details of the procedure, so be sure to review this procedure carefully. | + | The procedure is very similar to replacing the IP address, as outlined above. The main difference is that you will add new address entries to /etc/network/interfaces rather than editing the existing entries. This requires some other changes to details of the procedure, so be sure to review this procedure carefully. |
Back up your interfaces file. | Back up your interfaces file. | ||
Line 210: | Line 274: | ||
When your editor opens, you will see a file like this one: | When your editor opens, you will see a file like this one: | ||
<pre> | <pre> | ||
− | auto lo | + | # The loopback network interface |
− | iface lo inet loopback | + | auto lo |
+ | iface lo inet loopback | ||
+ | |||
+ | # The primary network interface | ||
+ | auto eth0 | ||
+ | iface eth0 inet static | ||
+ | address OLDIPV4ADDRESS | ||
+ | netmask 255.255.255.0 | ||
+ | gateway 64.62.188.1 | ||
+ | dns-nameservers 71.19.155.120 71.19.145.215 8.8.8.8 | ||
− | + | iface eth0 inet6 static | |
− | + | address OLDIPV6ADDRESS | |
− | iface eth0 | + | netmask 64 |
− | + | gateway 2001:470:1:41::1 | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
The addresses under ''iface eth0 inet static'' and ''iface eth0 inet6 static'' are your original IPv4 and IPv6 addresses, respectively. Edit the file to add entries for the new IPv4 and IPv6 addresses from your email, and make changes to the network, gateway, and DNS nameservers so the file looks like this: | The addresses under ''iface eth0 inet static'' and ''iface eth0 inet6 static'' are your original IPv4 and IPv6 addresses, respectively. Edit the file to add entries for the new IPv4 and IPv6 addresses from your email, and make changes to the network, gateway, and DNS nameservers so the file looks like this: | ||
<pre> | <pre> | ||
− | + | auto lo eth0 | |
− | auto lo | ||
− | |||
− | + | iface lo inet loopback | |
− | |||
− | iface | ||
− | |||
− | |||
− | + | iface eth0 inet static | |
− | iface eth0 | + | address NEWIP4ADDRESS |
− | + | network 71.19.155.0 | |
− | + | netmask 255.255.255.0 | |
+ | gateway 71.19.155.1 | ||
+ | dns-nameservers 71.19.155.120 71.19.145.215 8.8.8.8 | ||
− | + | iface eth0 inet6 static | |
− | iface eth0 | + | address NEWIPV6ADDRESS |
− | + | netmask 64 | |
− | + | gateway 2605:2700:0:17::1 | |
− | |||
− | |||
− | auto eth0:0 | + | auto eth0:0 |
− | iface eth0:0 | + | iface eth0:0 inet static |
− | + | address OLDIPV4ADDRESS | |
− | + | netmask 255.255.255.0 | |
− | + | ||
+ | iface eth0:0 inet6 static | ||
+ | address OLDIPV6ADDRESS | ||
+ | netmask 64 | ||
</pre> | </pre> | ||
Line 279: | Line 340: | ||
<pre> | <pre> | ||
ip addr show | ip addr show | ||
− | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default | + | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default |
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | ||
inet 127.0.0.1/8 scope host lo | inet 127.0.0.1/8 scope host lo | ||
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 ::1/128 scope host | + | inet6 ::1/128 scope host |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 | 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 | ||
link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff | link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff | ||
− | inet | + | inet OLDIPV4ADDRESS/24 brd 12.34.567.255 scope global eth0 |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet | + | inet NEWIPV4ADDRESS/24 brd 17.91.151.255 scope global eth0:0 |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 | + | inet6 NEWIPV6ADDRESS/64 scope global deprecated |
valid_lft forever preferred_lft 0sec | valid_lft forever preferred_lft 0sec | ||
− | inet6 | + | inet6 OLDIPV6ADDRESS/64 scope global |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 ab60::b600:aa:fe07:7a9b/64 scope link | + | inet6 ab60::b600:aa:fe07:7a9b/64 scope link |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
</pre> | </pre> | ||
Line 302: | Line 363: | ||
=== Adding a new IP address in CentOS/Fedora === | === Adding a new IP address in CentOS/Fedora === | ||
− | To add a new IP in CentOS or Fedora, you will need to add a second configuration file and make a few changes to your original file. | + | To add a new IP in CentOS or Fedora, you will need to add a second configuration file and make a few changes to your original file. |
Back up your IP configuration file. | Back up your IP configuration file. | ||
Line 314: | Line 375: | ||
</pre> | </pre> | ||
− | Add your new IPv4 | + | Add your new IPv4 and IPv6 addresses. Open your '''original''' IP configuration file with your preferred text editor. This example uses nano. |
<pre> | <pre> | ||
nano /etc/sysconfig/network-scripts/ifcfg-eth0 | nano /etc/sysconfig/network-scripts/ifcfg-eth0 | ||
Line 320: | Line 381: | ||
When your editor opens, you will see a file like this one: | When your editor opens, you will see a file like this one: | ||
− | <pre> | + | <pre> |
DEVICE=eth0 | DEVICE=eth0 | ||
− | IPADDR= | + | IPADDR=OLDIPV4ADDRESS |
NETMASK=255.255.255.0 | NETMASK=255.255.255.0 | ||
− | GATEWAY= | + | GATEWAY=64.62.188.1 |
NM_CONTROLLED=no | NM_CONTROLLED=no | ||
ONBOOT=yes | ONBOOT=yes | ||
− | DNS1= | + | DNS1=71.19.155.120 |
− | DNS2= | + | DNS2=71.19.145.215 |
SEARCH=xen.prgmr.com | SEARCH=xen.prgmr.com | ||
TYPE=Ethernet | TYPE=Ethernet | ||
Line 336: | Line 397: | ||
IPV6INIT=yes | IPV6INIT=yes | ||
− | IPV6ADDR= | + | IPV6ADDR=OLDIPV6ADDRESS/64 |
− | IPV6_DEFAULTGW=2001: | + | IPV6_DEFAULTGW=2001:470:1:41::1 |
</pre> | </pre> | ||
The addresses under ''IPADDR'' and ''IPV6ADDR'' are your original IPv4 and IPv6 addresses, respectively. Edit the file to add the new IPv6 address from your email, remove the GATEWAY entry, and add the new IPv6 gateway to the IPV6_DEFAULTGW field. Add a third DNS address. When you've finished, the file will look like this: | The addresses under ''IPADDR'' and ''IPV6ADDR'' are your original IPv4 and IPv6 addresses, respectively. Edit the file to add the new IPv6 address from your email, remove the GATEWAY entry, and add the new IPv6 gateway to the IPV6_DEFAULTGW field. Add a third DNS address. When you've finished, the file will look like this: | ||
<pre> | <pre> | ||
− | DEVICE=eth0 | + | DEVICE=eth0 |
− | + | BOOTPROTO=none | |
− | + | ONBOOT=yes | |
− | IPADDR= | + | TYPE=Ethernet |
− | NETMASK=255.255.255.0 | + | IPADDR=NEWIPV4ADDRESS |
− | + | NETMASK=255.255.255.0 | |
− | + | GATEWAY=71.19.155.1 | |
− | + | IPV6INIT=yes | |
− | + | IPV6ADDR="NEWIPV6ADDRESS" | |
− | + | IPV6AUTOCONF=no | |
− | + | IPV6_DEFAULTGW=2605:2700:0:17::1 | |
− | + | IPV6ADDR_SECONDARIES="OLDIPV6ADDRESS/64" | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | IPV6ADDR_SECONDARIES=" | ||
− | |||
</pre> | </pre> | ||
Save your changes and close the editor. | Save your changes and close the editor. | ||
− | Now, | + | Now, move your old IPv4 address to eth0:0. Using your preferred text editor, open the '''new''' IP configuration file that you created above. This example uses nano. |
<pre> | <pre> | ||
nano /etc/sysconfig/network-scripts/ifcfg-eth0:0 | nano /etc/sysconfig/network-scripts/ifcfg-eth0:0 | ||
Line 373: | Line 425: | ||
When your editor opens, you will see a file like this one: | When your editor opens, you will see a file like this one: | ||
− | <pre> | + | <pre> |
− | DEVICE=eth0 | + | DEVICE=eth0 |
− | IPADDR= | + | IPADDR=OLDIPV4ADDRESS |
− | NETMASK=255.255.255.0 | + | NETMASK=255.255.255.0 |
− | GATEWAY= | + | GATEWAY=64.62.188.1 |
− | NM_CONTROLLED=no | + | NM_CONTROLLED=no |
− | ONBOOT=yes | + | ONBOOT=yes |
− | DNS1= | + | DNS1=71.19.155.120 |
− | DNS2= | + | DNS2=71.19.145.215 |
− | SEARCH=xen.prgmr.com | + | SEARCH=xen.prgmr.com |
− | TYPE=Ethernet | + | TYPE=Ethernet |
− | BOOTPROTO=none | + | BOOTPROTO=none |
− | USERCTL=no | + | USERCTL=no |
− | PEERDNS=no | + | PEERDNS=no |
− | IPV6INIT=yes | + | IPV6INIT=yes |
− | IPV6ADDR= | + | IPV6ADDR=OLDIPV6ADDRESS/64 |
− | IPV6_DEFAULTGW=2001: | + | IPV6_DEFAULTGW=2001:470:1:41::1 |
</pre> | </pre> | ||
− | Remove the IPv6 entries | + | Remove the IPv6 entries and edit the file to look like this: |
<pre> | <pre> | ||
− | DEVICE=eth0:0 | + | DEVICE=eth0:0 |
− | + | BOOTPROTO=none | |
− | + | ONBOOT=yes | |
− | IPADDR= | + | TYPE=Ethernet |
− | NETMASK=255.255.255.0 | + | IPADDR=OLDIPV4ADDRESS |
− | + | NETMASK=255.255.255.0 | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
Line 427: | Line 469: | ||
</pre> | </pre> | ||
− | Verify the new IP addresses: | + | Verify the new IP addresses: |
<pre> | <pre> | ||
ip addr show | ip addr show | ||
− | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default | + | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default |
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | ||
inet 127.0.0.1/8 scope host lo | inet 127.0.0.1/8 scope host lo | ||
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 ::1/128 scope host | + | inet6 ::1/128 scope host |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 | 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 | ||
link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff | link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff | ||
− | inet | + | inet OLDIPV4ADDRESS/24 brd 12.34.567.255 scope global eth0 |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet | + | inet NEWIPV4ADDRESS/24 brd 17.91.151.255 scope global eth0:0 |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 | + | inet6 NEWIPV6ADDRESS/64 scope global deprecated |
valid_lft forever preferred_lft 0sec | valid_lft forever preferred_lft 0sec | ||
− | inet6 | + | inet6 OLDIPV6ADDRESS/64 scope global |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 ab60::b600:aa:fe07:7a9b/64 scope link | + | inet6 ab60::b600:aa:fe07:7a9b/64 scope link |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
</pre> | </pre> | ||
Line 453: | Line 495: | ||
== Removing an Old IP Address == | == Removing an Old IP Address == | ||
− | If you add a new address rather than replacing the old one, you will probably still want to remove the old address at some point. Follow these procedures to do that. | + | If you add a new address rather than replacing the old one, you will probably still want to remove the old address at some point. Follow these procedures to do that. |
=== Removing an old IP address in Debian/Ubuntu === | === Removing an old IP address in Debian/Ubuntu === | ||
− | This is simply a process of editing the interfaces file to remove the old addresses. | + | This is simply a process of editing the interfaces file to remove the old addresses. |
Back up your interfaces file. | Back up your interfaces file. | ||
Line 470: | Line 512: | ||
When your editor opens, you will see a file like this one: | When your editor opens, you will see a file like this one: | ||
<pre> | <pre> | ||
− | + | auto lo eth0 | |
− | auto lo | + | |
− | iface lo inet loopback | + | iface lo inet loopback |
− | + | iface eth0 inet static | |
− | + | address NEWIP4ADDRESS | |
− | iface eth0 inet static | + | network 71.19.155.0 |
− | + | netmask 255.255.255.0 | |
− | + | gateway 71.19.155.1 | |
+ | dns-nameservers 71.19.155.120 71.19.145.215 8.8.8.8 | ||
− | + | iface eth0 inet6 static | |
− | iface eth0 inet6 static | + | address NEWIPV6ADDRESS |
− | + | netmask 64 | |
− | + | gateway 2605:2700:0:17::1 | |
− | auto eth0:0 | + | auto eth0:0 |
− | iface eth0:0 inet static | + | iface eth0:0 inet static |
− | + | address OLDIPV4ADDRESS | |
− | + | netmask 255.255.255.0 | |
− | |||
− | |||
− | + | iface eth0:0 inet6 static | |
− | iface eth0:0 inet6 static | + | address OLDIPV6ADDRESS |
− | + | netmask 64 | |
− | |||
− | |||
</pre> | </pre> | ||
− | Delete the old IPv4 and IPv6 addresses and change eth0:0 to eth0. When you are finished the file should look like this: | + | Delete all the information for eth0:0, including the old IPv4 and IPv6 addresses and change eth0:0 to eth0. When you are finished the file should look like this: |
<pre> | <pre> | ||
− | + | auto lo eth0 | |
− | auto lo | + | |
− | iface lo inet loopback | + | iface lo inet loopback |
− | + | iface eth0 inet static | |
− | + | address NEWIP4ADDRESS | |
− | iface eth0 inet static | + | network 71.19.155.0 |
− | + | netmask 255.255.255.0 | |
− | + | gateway 71.19.155.1 | |
− | + | dns-nameservers 71.19.155.120 71.19.145.215 8.8.8.8 | |
− | |||
− | + | iface eth0 inet6 static | |
− | iface eth0 inet6 static | + | address NEWIPV6ADDRESS |
− | + | netmask 64 | |
− | + | gateway 2605:2700:0:17::1 | |
− | |||
</pre> | </pre> | ||
Line 540: | Line 577: | ||
<pre> | <pre> | ||
$ ip addr show | $ ip addr show | ||
− | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default | + | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default |
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | ||
inet 127.0.0.1/8 scope host lo | inet 127.0.0.1/8 scope host lo | ||
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 ::1/128 scope host | + | inet6 ::1/128 scope host |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 | 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 | ||
Line 550: | Line 587: | ||
inet 17.91.151.121/24 brd 17.91.151.255 scope global eth0 | inet 17.91.151.121/24 brd 17.91.151.255 scope global eth0 | ||
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 2605:2070:0:71:b600:aa:fe07:7a9b/64 scope global | + | inet6 2605:2070:0:71:b600:aa:fe07:7a9b/64 scope global |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 ab60::b600:aa:fe07:7a9b/64 scope link | + | inet6 ab60::b600:aa:fe07:7a9b/64 scope link |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
</pre> | </pre> | ||
Line 559: | Line 596: | ||
=== Removing an old IP address in CentOS/Fedora === | === Removing an old IP address in CentOS/Fedora === | ||
− | '''Important:''' Make certain that you have at least two configuration files before you delete one. | + | '''Important:''' Make certain that you have at least two configuration files before you delete one. |
− | Back up your old configuration files, just in case. | + | Back up your old configuration files, just in case. |
<pre> | <pre> | ||
cp -f --backup /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0 | cp -f --backup /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0 | ||
cp -f --backup /etc/sysconfig/network-scripts/ifcfg-eth0:0 /etc/sysconfig/network-scripts/ifcfg-eth0:0 | cp -f --backup /etc/sysconfig/network-scripts/ifcfg-eth0:0 /etc/sysconfig/network-scripts/ifcfg-eth0:0 | ||
+ | </pre> | ||
+ | |||
+ | Delete your eth0:0 file containing your old IPv4 address. | ||
+ | <pre> | ||
+ | $ rm /etc/sysconfig/network-scripts/ifcfg-eth0:0 | ||
</pre> | </pre> | ||
Line 574: | Line 616: | ||
When your editor opens, you will see a file like this one: | When your editor opens, you will see a file like this one: | ||
<pre> | <pre> | ||
− | DEVICE=eth0 | + | DEVICE=eth0 |
− | + | BOOTPROTO=none | |
− | + | ONBOOT=yes | |
− | IPADDR= | + | TYPE=Ethernet |
− | NETMASK=255.255.255.0 | + | IPADDR=NEWIPV4ADDRESS |
− | + | NETMASK=255.255.255.0 | |
− | + | GATEWAY=71.19.155.1 | |
− | + | IPV6INIT=yes | |
− | + | IPV6ADDR="NEWIPV6ADDRESS" | |
− | + | IPV6AUTOCONF=no | |
− | + | IPV6_DEFAULTGW=2605:2700:0:17::1 | |
− | + | IPV6ADDR_SECONDARIES="OLDIPV6ADDRESS/64" | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | IPV6ADDR_SECONDARIES=" | ||
− | |||
</pre> | </pre> | ||
− | + | Edit the file to look like this: | |
<pre> | <pre> | ||
− | DEVICE=eth0 | + | DEVICE=eth0 |
− | + | BOOTPROTO=none | |
− | + | ONBOOT=yes | |
− | + | TYPE=Ethernet | |
− | + | IPADDR=NEWIPV4ADDRESS | |
− | NETMASK=255.255.255.0 | + | NETMASK=255.255.255.0 |
− | + | GATEWAY=71.19.155.1 | |
− | + | IPV6INIT=yes | |
− | + | IPV6ADDR="NEWIPV6ADDRESS/64" | |
− | + | IPV6AUTOCONF=no | |
− | + | IPV6_DEFAULTGW=2605:2700:0:17::1 | |
− | + | </pre> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | IPV6INIT=yes | ||
− | IPV6ADDR= | ||
− | IPV6_DEFAULTGW=2605: | ||
− | </pre> | ||
− | |||
− | |||
− | + | Close the editor and save your changes. | |
− | |||
− | |||
− | |||
Activate your changes: | Activate your changes: | ||
Line 641: | Line 659: | ||
</pre> | </pre> | ||
− | Verify the new IP configuration: | + | Verify the new IP configuration: |
<pre> | <pre> | ||
$ ip addr show | $ ip addr show | ||
− | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default | + | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default |
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | ||
inet 127.0.0.1/8 scope host lo | inet 127.0.0.1/8 scope host lo | ||
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 ::1/128 scope host | + | inet6 ::1/128 scope host |
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 | 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 | ||
link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff | link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff | ||
− | inet | + | inet NEWIPV4ADDRESS/24 brd 17.91.151.255 scope global eth0 |
+ | inet6 NEWIPV6ADDRESS/64 scope global | ||
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
− | inet6 | + | inet6 fe80::a800:ff:fe13:9b7a/64 scope link |
− | |||
− | |||
valid_lft forever preferred_lft forever | valid_lft forever preferred_lft forever | ||
</pre> | </pre> | ||
− | + | ||
Go to [[#Testing your connection]]. | Go to [[#Testing your connection]]. | ||
Revision as of 01:50, 17 October 2016
Unfamiliar with IPv6? Try Hurricane Electric's free IPv6 certification. |
Contents
Introduction
You may have received an email telling you of a change to your IP addresses. The email tells you how to replace your old IP addresses with the new ones. This wiki page expands on that procedure and adds a few more for adding and removing addresses. If you have not received an email about your IP addresses then this procedure does not apply to you.
If you have two addresses, then you have a choice: you can change your old IP address to the new address, or you can add the new address and run both at once. See below for some pros and cons of each.
If you have received an email from us about replacing or adding an IP address, then refer there for your old and new addresses. Your email comes with several attachments (two scripts and a number of configuration files) that may simplify the process.
Change Your IP Address or Add One? Pros and Cons
There are three options here: replacing your original addresses with the new ones, adding the new addresses and running them together with the originals, or adding the new addresses and then deleting the originals at a later date.
Replacing your IP addresses is the simplest option. However it means taking your network interface offline briefly, and it takes some time (up to 24 hours) to propagate the change to the DNS servers that map your IP addresses. During that time your service will be down.
Adding the new IP addresses is a little more complex, but does not take your service offline. Your original IP addresses still map to you while the new ones are propagating to the DNS servers. However you still will need to remove the original IP addresses when and if we move away from HE.net. If the original IP addresses are still the defaults then an outage on HE.net will take your service down even if you have another IP address with a different provider.
It is possible to add the new IP addresses and then remove the old ones. This is the most complex of the three options, but it avoids present downtime and future problems with the original IP addresses.
Using the Sample Files
The email with your new IP addresses came with several attachments. You will #Using the IP Scripts only for #Adding a New IP Address. They are intended as a convenience to allow you to bring down your interfaces at a convenient time. You may use the attached configuration files to cut and paste when editing your IP configuration files in the following procedures.
Replacing Your IP Address
To replace the IP address in Debian derivatives (we provide Debian and Ubuntu images) or Red Hat derivatives (CentOS and Fedora) you will edit a file. For other distros, check your user documentation.
Replacing your IP address in Debian/Ubuntu
Back up your interfaces file.
cp -f --backup /etc/network/interfaces /etc/network/interfaces
Open your interfaces file with your preferred text editor. This example uses nano.
nano /etc/network/interfaces
When your editor opens, you will see a file like this one:
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address OLDIPV4ADDRESS netmask 255.255.255.0 gateway 64.62.188.1 dns-nameservers 71.19.155.120 71.19.145.215 8.8.8.8 iface eth0 inet6 static address OLDIPV6ADDRESS netmask 64 gateway 2001:470:1:41::1
The addresses under iface eth0 inet static and iface eth0 inet6 static are your original IPv4 and IPv6 addresses, respectively. Edit the file to replace the IPv4 and IPv6 addresses with the new ones from your email, and make changes to the network, gateway, and DNS nameservers so the file looks like this:
auto lo eth0 iface lo inet loopback iface eth0 inet static address NEWIPV4ADDRESS network 71.19.155.0 netmask 255.255.255.0 gateway 71.19.155.1 dns-nameservers 71.19.155.120 71.19.145.215 8.8.8.8 iface eth0 inet6 static address NEWIPV6ADDRESS netmask 64 gateway 2605:2700:0:17::1
Save the file, exit the editor, then flush the interfaces.
$ /sbin/ip addr flush dev eth0
Enable the changes you've made by bringing the interface down, then bringing it up again.
Important: If you are connected directly via SSH, you won't be able to send any more commands after bringing down the interface, so make sure you bring the interface back up in the same command:
ifdown eth0 && ifup eth0
Verify the changes to your IP addresses
$ ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff inet NEWIPV4ADDRESS/24 brd 71.19.155.255 scope global eth0 valid_lft forever preferred_lft forever inet6 NEWIPV6ADDRESS/64 scope global valid_lft forever preferred_lft forever inet6 fe80::a800:ff:fe13:9b7a/64 scope link valid_lft forever preferred_lft forever
Go to #Testing your connection.
Replacing your IP address in CentOS/Fedora
Back up your IP configuration file.
cp -f --backup /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0
Open your IP configuration file with your preferred text editor. This example uses nano.
nano /etc/sysconfig/network-scripts/ifcfg-eth0
When your editor opens, you will see a file like this one:
DEVICE=eth0 IPADDR=OLDIPV4ADDRESS NETMASK=255.255.255.0 GATEWAY=64.62.188.1 NM_CONTROLLED=no ONBOOT=yes DNS1=71.19.155.120 DNS2=71.19.145.215 SEARCH=xen.prgmr.com TYPE=Ethernet BOOTPROTO=none USERCTL=no PEERDNS=no IPV6INIT=yes IPV6ADDR=OLDIPV6ADDRESS/64 IPV6_DEFAULTGW=2001:470:1:41::1
The addresses under IPADDR and IPV6ADDR are your original IPv4 and IPv6 addresses, respectively. Edit the file to look like this:
DEVICE=eth0 BOOTPROTO=none ONBOOT=yes TYPE=Ethernet IPADDR=NEWIPV4ADDRESS NETMASK=255.255.255.0 GATEWAY=71.19.155.1 IPV6INIT=yes IPV6ADDR="NEWIPV6ADDRESS/64" IPV6AUTOCONF=no IPV6_DEFAULTGW=2605:2700:0:17::1
Activate your changes:
$ service network restart Shutting down interface eth0: [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: lo: Disabled Privacy Extensions [ OK ] Bringing up interface eth0: Determining if ip address 17.91.151.121 is already in use for device eth0... [ OK ]
Verify the new IP addresses:
$ ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff inet NEWIPV4ADDRESS/24 brd 17.91.151.255 scope global eth0 inet6 NEWIPV6ADDRESS/64 scope global valid_lft forever preferred_lft forever inet6 fe80::a800:ff:fe13:9b7a/64 scope link valid_lft forever preferred_lft forever
Go to #Testing your connection.
Adding a New IP Address
To add an IP address in Debian derivatives (we provide Debian and Ubuntu images) you will edit a file. For Red Hat derivatives (CentOS and Fedora) you will add a new file. For other distros, check your user documentation.
Using the IP Scripts
If you received an email notifying you of your new IP addresses, then you also received two scripts. You can use these scripts to make a temporary change to your IP addresses without bringing your interface down.
Important: The scripts you received make a temporary change to the state of your system - implementing the new IP addresses with no need to bring the interface down and then up again. However these changes are not reflected in your IP configuration files. You must still update your configuration files with the new IP addresses before your reboot your system (either deliberately or otherwise). If you do not then the system will revert to its original state after reboot.
Transferring the Scripts
If you have transferred files before between your local system and your VPS then use your favorite method. If not then run the following command on your local system, inserting the file names as needed. This command will copy the scripts to the /home directory of your VPS.
scp -i ~/.ssh/SSH_KEY [LOCAL_FILE_PATH] [USERNAME]@[USERNAME].xen.prgmr.com:
If your local OS is not Linux, or if this command fails for any reason, then you can open the scripts in a local text editor and paste them into nano on your VPS. Save the nano files to your preferred directory for running scripts.
Running the Scripts
First, you will add your new IP addresses.
./add-new-ips
Verify the changes.
ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff inet OLDIPV4ADDRESS/24 brd 64.62.188.255 scope global eth0 valid_lft forever preferred_lft forever inet NEWIPV4ADDRESS/24 scope global eth0 valid_lft forever preferred_lft forever inet6 NEWIPV6ADDRESS/64 scope global valid_lft forever preferred_lft forever inet6 OLDIPV6ADDRESS/64 scope global valid_lft forever preferred_lft forever inet6 fe80::a800:ff:fe13:9b7a/64 scope link valid_lft forever preferred_lft forever
Go to #Testing your connection.
Whenever you are ready to transfer completely to the new IP addresses, run your remove script.
./rm-old-ips
And again, verify the changes.
ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff inet NEWIPV4ADDRESS/24 brd 71.19.155.255 scope global eth0 valid_lft forever preferred_lft forever inet6 NEWIPV6ADDRESS/64 scope global valid_lft forever preferred_lft forever inet6 fe80::a800:ff:fe13:9b7a/64 scope link valid_lft forever preferred_lft forever
Remember that you must update your configuration files as outlined below before rebooting your system.
Adding a new IP address in Debian/Ubuntu
The procedure is very similar to replacing the IP address, as outlined above. The main difference is that you will add new address entries to /etc/network/interfaces rather than editing the existing entries. This requires some other changes to details of the procedure, so be sure to review this procedure carefully.
Back up your interfaces file.
cp -f --backup /etc/network/interfaces /etc/network/interfaces
Open your interfaces file with your preferred text editor. This example uses nano.
nano /etc/network/interfaces
When your editor opens, you will see a file like this one:
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address OLDIPV4ADDRESS netmask 255.255.255.0 gateway 64.62.188.1 dns-nameservers 71.19.155.120 71.19.145.215 8.8.8.8 iface eth0 inet6 static address OLDIPV6ADDRESS netmask 64 gateway 2001:470:1:41::1
The addresses under iface eth0 inet static and iface eth0 inet6 static are your original IPv4 and IPv6 addresses, respectively. Edit the file to add entries for the new IPv4 and IPv6 addresses from your email, and make changes to the network, gateway, and DNS nameservers so the file looks like this:
auto lo eth0 iface lo inet loopback iface eth0 inet static address NEWIP4ADDRESS network 71.19.155.0 netmask 255.255.255.0 gateway 71.19.155.1 dns-nameservers 71.19.155.120 71.19.145.215 8.8.8.8 iface eth0 inet6 static address NEWIPV6ADDRESS netmask 64 gateway 2605:2700:0:17::1 auto eth0:0 iface eth0:0 inet static address OLDIPV4ADDRESS netmask 255.255.255.0 iface eth0:0 inet6 static address OLDIPV6ADDRESS netmask 64
Save the file and exit the editor.
Flush all interfaces to clear existing IP addresses.
ip addr flush dev eth0 ip addr flush dev eth0:0
Bring your interfaces down and bring them back up to implement your new IP addresses.
Important: If you are connected directly via SSH, you won't be able to send any more commands after bringing down the interface, so make sure you bring the interface back up in the same command:
ifdown eth0 && ifup eth0 && ifup eth0:0
Verify the changes to your IP addresses:
ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff inet OLDIPV4ADDRESS/24 brd 12.34.567.255 scope global eth0 valid_lft forever preferred_lft forever inet NEWIPV4ADDRESS/24 brd 17.91.151.255 scope global eth0:0 valid_lft forever preferred_lft forever inet6 NEWIPV6ADDRESS/64 scope global deprecated valid_lft forever preferred_lft 0sec inet6 OLDIPV6ADDRESS/64 scope global valid_lft forever preferred_lft forever inet6 ab60::b600:aa:fe07:7a9b/64 scope link valid_lft forever preferred_lft forever
Go to #Testing your connection.
Adding a new IP address in CentOS/Fedora
To add a new IP in CentOS or Fedora, you will need to add a second configuration file and make a few changes to your original file.
Back up your IP configuration file.
cp -f --backup /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0
To save yourself some work, make your new configuration file by copying the original.
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
Add your new IPv4 and IPv6 addresses. Open your original IP configuration file with your preferred text editor. This example uses nano.
nano /etc/sysconfig/network-scripts/ifcfg-eth0
When your editor opens, you will see a file like this one:
DEVICE=eth0 IPADDR=OLDIPV4ADDRESS NETMASK=255.255.255.0 GATEWAY=64.62.188.1 NM_CONTROLLED=no ONBOOT=yes DNS1=71.19.155.120 DNS2=71.19.145.215 SEARCH=xen.prgmr.com TYPE=Ethernet BOOTPROTO=none USERCTL=no PEERDNS=no IPV6INIT=yes IPV6ADDR=OLDIPV6ADDRESS/64 IPV6_DEFAULTGW=2001:470:1:41::1
The addresses under IPADDR and IPV6ADDR are your original IPv4 and IPv6 addresses, respectively. Edit the file to add the new IPv6 address from your email, remove the GATEWAY entry, and add the new IPv6 gateway to the IPV6_DEFAULTGW field. Add a third DNS address. When you've finished, the file will look like this:
DEVICE=eth0 BOOTPROTO=none ONBOOT=yes TYPE=Ethernet IPADDR=NEWIPV4ADDRESS NETMASK=255.255.255.0 GATEWAY=71.19.155.1 IPV6INIT=yes IPV6ADDR="NEWIPV6ADDRESS" IPV6AUTOCONF=no IPV6_DEFAULTGW=2605:2700:0:17::1 IPV6ADDR_SECONDARIES="OLDIPV6ADDRESS/64"
Save your changes and close the editor.
Now, move your old IPv4 address to eth0:0. Using your preferred text editor, open the new IP configuration file that you created above. This example uses nano.
nano /etc/sysconfig/network-scripts/ifcfg-eth0:0
When your editor opens, you will see a file like this one:
DEVICE=eth0 IPADDR=OLDIPV4ADDRESS NETMASK=255.255.255.0 GATEWAY=64.62.188.1 NM_CONTROLLED=no ONBOOT=yes DNS1=71.19.155.120 DNS2=71.19.145.215 SEARCH=xen.prgmr.com TYPE=Ethernet BOOTPROTO=none USERCTL=no PEERDNS=no IPV6INIT=yes IPV6ADDR=OLDIPV6ADDRESS/64 IPV6_DEFAULTGW=2001:470:1:41::1
Remove the IPv6 entries and edit the file to look like this:
DEVICE=eth0:0 BOOTPROTO=none ONBOOT=yes TYPE=Ethernet IPADDR=OLDIPV4ADDRESS NETMASK=255.255.255.0
Save your changes and close the editor.
Activate your changes:
$ service network restart Shutting down interface eth0: [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: lo: Disabled Privacy Extensions [ OK ] Bringing up interface eth0: Determining if ip address 12.34.567.89 is already in use for device eth0... Determining if ip address 17.91.151.121 is already in use for device eth0... [ OK ]
Verify the new IP addresses:
ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff inet OLDIPV4ADDRESS/24 brd 12.34.567.255 scope global eth0 valid_lft forever preferred_lft forever inet NEWIPV4ADDRESS/24 brd 17.91.151.255 scope global eth0:0 valid_lft forever preferred_lft forever inet6 NEWIPV6ADDRESS/64 scope global deprecated valid_lft forever preferred_lft 0sec inet6 OLDIPV6ADDRESS/64 scope global valid_lft forever preferred_lft forever inet6 ab60::b600:aa:fe07:7a9b/64 scope link valid_lft forever preferred_lft forever
Go to #Testing your connection.
Removing an Old IP Address
If you add a new address rather than replacing the old one, you will probably still want to remove the old address at some point. Follow these procedures to do that.
Removing an old IP address in Debian/Ubuntu
This is simply a process of editing the interfaces file to remove the old addresses.
Back up your interfaces file.
cp -f --backup /etc/network/interfaces /etc/network/interfaces
Open your interfaces file with your preferred text editor. This example uses nano.
nano /etc/network/interfaces
When your editor opens, you will see a file like this one:
auto lo eth0 iface lo inet loopback iface eth0 inet static address NEWIP4ADDRESS network 71.19.155.0 netmask 255.255.255.0 gateway 71.19.155.1 dns-nameservers 71.19.155.120 71.19.145.215 8.8.8.8 iface eth0 inet6 static address NEWIPV6ADDRESS netmask 64 gateway 2605:2700:0:17::1 auto eth0:0 iface eth0:0 inet static address OLDIPV4ADDRESS netmask 255.255.255.0 iface eth0:0 inet6 static address OLDIPV6ADDRESS netmask 64
Delete all the information for eth0:0, including the old IPv4 and IPv6 addresses and change eth0:0 to eth0. When you are finished the file should look like this:
auto lo eth0 iface lo inet loopback iface eth0 inet static address NEWIP4ADDRESS network 71.19.155.0 netmask 255.255.255.0 gateway 71.19.155.1 dns-nameservers 71.19.155.120 71.19.145.215 8.8.8.8 iface eth0 inet6 static address NEWIPV6ADDRESS netmask 64 gateway 2605:2700:0:17::1
Save the file and exit the editor.
Flush all interfaces to clear existing IP addresses.
ip addr flush dev eth0 ip addr flush dev eth0:0
Bring your interfaces down and bring them back up to implement your new IP addresses.
Important: If you are connected directly via SSH, you won't be able to send any more commands after bringing down the interface, so make sure you bring the interface back up in the same command:
ifdown eth0 && ifup eth0
Verify the changes to your IP addresses:
$ ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff inet 17.91.151.121/24 brd 17.91.151.255 scope global eth0 valid_lft forever preferred_lft forever inet6 2605:2070:0:71:b600:aa:fe07:7a9b/64 scope global valid_lft forever preferred_lft forever inet6 ab60::b600:aa:fe07:7a9b/64 scope link valid_lft forever preferred_lft forever
Go to #Testing your connection.
Removing an old IP address in CentOS/Fedora
Important: Make certain that you have at least two configuration files before you delete one.
Back up your old configuration files, just in case.
cp -f --backup /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0 cp -f --backup /etc/sysconfig/network-scripts/ifcfg-eth0:0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
Delete your eth0:0 file containing your old IPv4 address.
$ rm /etc/sysconfig/network-scripts/ifcfg-eth0:0
Open your eth0 IP configuration file with your preferred text editor. This example uses nano.
nano /etc/sysconfig/network-scripts/ifcfg-eth0
When your editor opens, you will see a file like this one:
DEVICE=eth0 BOOTPROTO=none ONBOOT=yes TYPE=Ethernet IPADDR=NEWIPV4ADDRESS NETMASK=255.255.255.0 GATEWAY=71.19.155.1 IPV6INIT=yes IPV6ADDR="NEWIPV6ADDRESS" IPV6AUTOCONF=no IPV6_DEFAULTGW=2605:2700:0:17::1 IPV6ADDR_SECONDARIES="OLDIPV6ADDRESS/64"
Edit the file to look like this:
DEVICE=eth0 BOOTPROTO=none ONBOOT=yes TYPE=Ethernet IPADDR=NEWIPV4ADDRESS NETMASK=255.255.255.0 GATEWAY=71.19.155.1 IPV6INIT=yes IPV6ADDR="NEWIPV6ADDRESS/64" IPV6AUTOCONF=no IPV6_DEFAULTGW=2605:2700:0:17::1
Close the editor and save your changes.
Activate your changes:
$ service network restart Shutting down interface eth0: [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: lo: Disabled Privacy Extensions [ OK ] Bringing up interface eth0: Determining if ip address 17.91.151.121 is already in use for device eth0... [ OK ]
Verify the new IP configuration:
$ ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether aa:00:00:13:9b:7a brd ff:ff:ff:ff:ff:ff inet NEWIPV4ADDRESS/24 brd 17.91.151.255 scope global eth0 inet6 NEWIPV6ADDRESS/64 scope global valid_lft forever preferred_lft forever inet6 fe80::a800:ff:fe13:9b7a/64 scope link valid_lft forever preferred_lft forever
Go to #Testing your connection.
Testing your connection
After you change, add, or remove an IP address, it is a good idea to test the connection with ping.
Test IPv4:
$ ping -c1 google.com PING google.com (173.194.203.102) 56(84) bytes of data. 64 bytes from pg-in-f102.1e100.net (173.194.203.102): icmp_seq=1 ttl=47 time=22.7 ms --- google.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 46ms rtt min/avg/max/mdev = 22.750/22.750/22.750/0.000 ms
Test IPv6:
$ ping6 -c1 ipv6.google.com PING ipv6.google.com(nuq05s02-in-x0e.1e100.net) 56 data bytes 64 bytes from nuq05s02-in-x0e.1e100.net: icmp_seq=1 ttl=58 time=1.71 ms --- ipv6.google.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 1ms rtt min/avg/max/mdev = 1.711/1.711/1.711/0.000 ms
Congratulations, your new addresses are now up and running.
You may also want to test your connection from the outside. You can use the tools at http://www.berkom.blazing.de/ or browse your website with ipv6 using http://www.sixxs.net/tools/gateway/