Changing, Adding, and Removing IP Addresses
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.
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.
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:
auto lo eth0 iface lo inet loopback #IPv4 Address auto eth0 iface eth0 inet static address 12.34.567.89 netmask 255.255.255.0 gateway 12.34.567.1 dns-nameservers 11.12.155.120 11.12.145.215 #IPv6 Address auto eth0 iface eth0 inet6 static address 2001:750:1:13:f500:aa:fe03:7a9b netmask 64 gateway 2001:750:1:13::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:
# The loopback network interface auto lo eth0 iface lo inet loopback auto eth0 iface eth0 inet static address 17.91.151.121 netmask 255.255.255.0 gateway 17.91.151.1 dns-nameservers 11.12.155.120 11.12.145.215 8.8.8.8 auto eth0 iface eth0 inet6 static address 2605:2070:0:71:b600:aa:fe07:7a9b netmask 64 gateway 2605:2070:0:71::1
Save the file, exit the editor, then 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 pfifo_fast 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.
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=12.34.567.89 NETMASK=255.255.255.0 GATEWAY=12.34.567.1 NM_CONTROLLED=no ONBOOT=yes DNS1=11.12.155.120 DNS2=11.12.145.215 SEARCH=xen.prgmr.com TYPE=Ethernet BOOTPROTO=none USERCTL=no PEERDNS=no IPV6INIT=yes IPV6ADDR=2001:750:1:13:f500:aa:fe03:7a9b/64 IPV6_DEFAULTGW=2001:750:1:13::1
The addresses under IPADDR and IPV6ADDR 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, enter your new gateways in the GATEWAY and IPV6_DEFAULTGW fields, and add a third DNS address so the file looks like this:
DEVICE=eth0 # IPv4 Address IPADDR=17.91.151.121 NETMASK=255.255.255.0 GATEWAY=17.91.151.1 NM_CONTROLLED=no ONBOOT=yes DNS1=11.12.155.120 DNS2=11.12.145.215 DNS3=8.8.8.8 SEARCH=xen.prgmr.com TYPE=Ethernet BOOTPROTO=none USERCTL=no PEERDNS=no #IPv6 Address IPV6INIT=yes IPV6ADDR="2605:2070:0:71:b600:aa:fe07:7a9b/64" IPV6_DEFAULTGW=2605:2070:0:71::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 71.19.155.122 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 17.91.151.121/24 brd 17.91.151.255 scope global eth0 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.
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.
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:
auto lo eth0 iface lo inet loopback #IPv4 Address auto eth0 iface eth0 inet static address 12.34.567.89 netmask 255.255.255.0 gateway 12.34.567.1 dns-nameservers 11.12.155.120 11.12.145.215 #IPv6 Address auto eth0 iface eth0 inet6 static address 2001:750:1:13:f500:aa:fe03:7a9b netmask 64 gateway 2001:750:1:13::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:
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 12.34.567.89 netmask 255.255.255.0 auto eth0 iface eth0 inet6 static address 2001:750:1:13:f500:aa:fe03:7a9b netmask 64 auto eth0:0 iface eth0:0 inet static address 17.91.151.121 netmask 255.255.255.0 gateway 17.91.151.1 dns-nameservers 11.12.155.120 11.12.145.215 8.8.8.8 auto eth0:0 iface eth0:0 inet6 static address 2605:2070:0:71:b600:aa:fe07:7a9b netmask 64 gateway 2605:2070:0:71::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 && 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 12.34.567.89/24 brd 12.34.567.255 scope global eth0 valid_lft forever preferred_lft forever inet 17.91.151.121/24 brd 17.91.151.255 scope global eth0:0 valid_lft forever preferred_lft forever inet6 2605:2070:0:71:b600:aa:fe07:7a9b/64 scope global deprecated valid_lft forever preferred_lft 0sec inet6 2001:750:1:13:f500:aa:fe03: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.
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 address. 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=12.34.567.89 NETMASK=255.255.255.0 GATEWAY=12.34.567.1 NM_CONTROLLED=no ONBOOT=yes DNS1=11.12.155.120 DNS2=11.12.145.215 SEARCH=xen.prgmr.com TYPE=Ethernet BOOTPROTO=none USERCTL=no PEERDNS=no IPV6INIT=yes IPV6ADDR=2001:750:1:13:f500:aa:fe03:7a9b/64 IPV6_DEFAULTGW=2001:750:1:13::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 # Original IPv4 Address IPADDR=12.34.567.89 NETMASK=255.255.255.0 NM_CONTROLLED=no ONBOOT=yes DNS1=11.12.155.120 DNS2=11.12.145.215 DNS3=8.8.8.8 SEARCH=xyx.com TYPE=Ethernet BOOTPROTO=none USERCTL=no PEERDNS=no # Original and New IPv6 Addresses IPV6INIT=yes IPV6ADDR=2001:750:1:13:f500:aa:fe03:7a9b/64 IPV6ADDR_SECONDARIES="2605:2070:0:71:b600:aa:fe07:7a9b/64" IPV6_DEFAULTGW=2605:2070:0:71::1
Save your changes and close the editor.
Now, add your new IPv4 address. Open your new IP configuration file with your preferred text editor. 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=12.34.567.89 NETMASK=255.255.255.0 GATEWAY=12.34.567.1 NM_CONTROLLED=no ONBOOT=yes DNS1=11.12.155.120 DNS2=11.12.145.215 SEARCH=xen.prgmr.com TYPE=Ethernet BOOTPROTO=none USERCTL=no PEERDNS=no IPV6INIT=yes IPV6ADDR=2001:750:1:13:f500:aa:fe03:7a9b/64 IPV6_DEFAULTGW=2001:750:1:13::1
Remove the IPv6 entries. Add your new IPv4 address to the IPADDR field, and the new gateway and DNS address. Change the DEVICE field to eth0:0. When you are finished the file should look like this:
DEVICE=eth0:0 # New IPv4 Address IPADDR=17.91.151.121 NETMASK=255.255.255.0 GATEWAY=17.91.151.1 NM_CONTROLLED=no ONBOOT=yes DNS1=11.12.155.120 DNS2=11.12.145.215 DNS3=8.8.8.8 SEARCH=xen.prgmr.com TYPE=Ethernet BOOTPROTO=none USERCTL=no PEERDNS=no
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 64.62.188.5 is already in use for device eth0... Determining if ip address 71.19.155.122 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 12.34.567.89/24 brd 12.34.567.255 scope global eth0 valid_lft forever preferred_lft forever inet 17.91.151.121/24 brd 17.91.151.255 scope global eth0:0 valid_lft forever preferred_lft forever inet6 2605:2070:0:71:b600:aa:fe07:7a9b/64 scope global deprecated valid_lft forever preferred_lft 0sec inet6 2001:750:1:13:f500:aa:fe03: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
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:
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 12.34.567.89 netmask 255.255.255.0 auto eth0 iface eth0 inet6 static address 2001:750:1:13:f500:aa:fe03:7a9b netmask 64 auto eth0:0 iface eth0:0 inet static address 17.91.151.121 netmask 255.255.255.0 gateway 17.91.151.1 dns-nameservers 11.12.155.120 11.12.145.215 8.8.8.8 auto eth0:0 iface eth0:0 inet6 static address 2605:2070:0:71:b600:aa:fe07:7a9b netmask 64 gateway 2605:2070:0:71::1
Delete the old IPv4 and IPv6 addresses and change eth0:0 to eth0. When you are finished the file should look like this:
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 17.91.151.121 netmask 255.255.255.0 gateway 17.91.151.1 dns-nameservers 11.12.155.120 11.12.145.215 8.8.8.8 auto eth0 iface eth0 inet6 static address 2605:2070:0:71:b600:aa:fe07:7a9b netmask 64 gateway 2605:2070:0:71::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
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 # Original IPv4 Address IPADDR=64.62.188.5 NETMASK=255.255.255.0 NM_CONTROLLED=no ONBOOT=yes DNS1=71.19.155.120 DNS2=71.19.145.215 DNS3=8.8.8.8 SEARCH=xyx.com TYPE=Ethernet BOOTPROTO=none USERCTL=no PEERDNS=no # Original and New IPv6 Addresses IPV6INIT=yes IPV6ADDR=2001:470:1:41::403e:bc05/64 IPV6ADDR_SECONDARIES="2605:2700:0:17:a800:ff:fe13:9b7a/64" IPV6_DEFAULTGW=2605:2700:0:17::1
Move the new IPv6 address to the IPV6ADDR field, replacing the old address. Remove the IPV6ADDR_SECONDARIES field. Replace IPADDR with the new IPv4 address and add the GATEWAY field. When you are finished the file should look like this:
DEVICE=eth0 # IPv4 Address IPADDR=71.19.155.122 GATEWAY=71.19.155.1 NETMASK=255.255.255.0 NM_CONTROLLED=no ONBOOT=yes DNS1=71.19.155.120 DNS2=71.19.145.215 DNS3=8.8.8.8 SEARCH=xyx.com TYPE=Ethernet BOOTPROTO=none USERCTL=no PEERDNS=no # New IPv6 Address IPV6INIT=yes IPV6ADDR=2605:2700:0:17:a800:ff:fe13:9b7a/64 IPV6_DEFAULTGW=2605:2700:0:17::1
Close the editor and save your changes.
Delete ifcfg-eth0:0.
rm /etc/sysconfig/network-scripts/ifcfg-eth0:0
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 71.19.155.122 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 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 71.19.155.122/24 brd 71.19.155.255 scope global eth0 inet6 2605:2700:0:17:a800:ff:fe13:9b7a/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/