Difference between revisions of "Changing, Adding, and Removing IP Addresses"
(→Using the Sample Files) |
|||
Line 18: | Line 18: | ||
== Using the Sample Files == | == Using the Sample Files == | ||
− | The email with your new IP addresses came with several attachments, including two scripts 'add-new-ips' and 'rm-old-ips'. You will use these scripts only for [[#Adding | + | The email with your new IP addresses came with several attachments, including two scripts 'add-new-ips' and 'rm-old-ips'. You will use these scripts only for [[#Adding an IP Address]]. You may copy from the attached configuration files when editing your IP configuration files in the following procedures. |
== Replacing an IP Address == | == Replacing an IP Address == |
Latest revision as of 05:52, 15 February 2018
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. If you have not received an email about your IP addresses then this procedure does not apply to you.
Refer to the email you received 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 two options here: replacing your original addresses with the new ones or or adding the new addresses and 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 if you own your own domain name that points to the original IP address, changing that domain name to point to the new IP addresses may take up to 24 hours. During that time your site will be unreachable for anyone who has the old DNS entry cached.
Adding the new IP addresses is a little more complex, but does not take your service offline. Your original IP addresses still work while changes to DNS are propagating. However if the original IP addresses are still used for the default gateways or for DNS, then an outage on HE.net will take your service down. Our procedures set the new IP address as the default. You still will need to remove the original IP addresses when and if we move away from HE.net.
Using the Sample Files
The email with your new IP addresses came with several attachments, including two scripts 'add-new-ips' and 'rm-old-ips'. You will use these scripts only for #Adding an IP Address. You may copy from the attached configuration files when editing your IP configuration files in the following procedures.
Replacing an 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 IPs in Debian/Ubuntu
Start by verifying you can log into the VPS using option 1. of the Management Console.
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 and exit the editor.
Log into the VPS using option 1. of the Management Console. From there, 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.
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 IPs in CentOS/Fedora
Start by verifying you can log into the VPS using option 1. of the Management Console.
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 after logging in using option 1. of the Management Console:
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 an 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.
Adding IPs in Debian/Ubuntu
Start by verifying you can log into the VPS using option 1. of the Management Console.
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.
Log in to your VPS using option 1. of the Management Console.
At this point you can either run the provided script "add-new-ips" or use the distribution network scripts. "add-new-ips" will add the IP addresses without taking your network down, but it will not test the permanent configuration.
To test the permanent configuration (which takes down the network temporarily) run the following:
ip addr flush dev eth0
Bring your interfaces down and bring them back up to implement your new IP addresses.
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 IPs in CentOS/Fedora
Start by verifying you can log into the VPS using option 1. of the Management Console.
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.
Log in to your VPS using option 1. of the Management Console.
At this point you can either run the provided script "add-new-ips" or use the distribution network scripts. "add-new-ips" will add the IP addresses without taking your network down, but it will not test the permanent configuration.
To test the permanent configuration instead (which takes down the network temporarily) run the following:
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 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 IPs in Debian/Ubuntu
Start by verifying you can log into the VPS using option 1. of the Management Console.
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.
Log in to your VPS using option 1. of the Management Console.
At this point you can either run the provided script "rm-old-ips" or use the distribution network scripts. "rm-old-ips" will remove the old IP addresses without taking your network down, but it will not test the permanent configuration.
To test the permanent configuration (which takes down the network temporarily):
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.
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 IPs in CentOS/Fedora
Start by verifying you can log into the VPS using option 1. of the Management Console.
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.
Log in to your VPS using option 1. of the Management Console.
At this point you can either run the provided script "rm-old-ips" or use the distribution network scripts. "rm-old-ips" will remove the old IP addresses without taking your network down, but it will not test the permanent configuration.
To test the permanent configuration (which takes down the network temporarily) run the following:
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.