When adding IPs to our cloud servers, we need to keep in mind that each cloud server only has two interfaces — the public and private interface. Because of this, we’ll need to add each new IP as an alias instead of an entirely new interface. Adding a virtual IP to your CentOS server is simple, as we’ll see.

Adding your Additional Public IP in the Cloud Control Panel

We’ll start by logging in to the Atlantic.Net Cloud control panel.

 

Navigate to your ‘Public IPs‘ section.

We begin by clicking on “Reserve IP“.  A popup box will appear asking for the IP Location and Count of public IPs to add. For IP Location, select the same location as your Atlantic.Net CentOS server. We only want to add one IP address, so we will enter “1” for Count.  Now click “Reserve Public IP.”

We can now see a new IP address displayed under “Public IPs.”

Click on the checkbox next to the newly reserved public IP address, and choose to “Assign IP“.  (Note: You can assign the IP to any of the servers in the same location that IP was reserved. For this tutorial, we will assume you want to assign this IP to a CentOS server.)

Once the IP is assigned, it should look something like this:

Now we can move on to adding the IP to the actual server’s network interface.

Adding your Additional IP to CentOS 6.X/7.X

When starting, either SSH into your server (Windows / Linux) or access it via the Cloud control panel console we offer.

login as: root
root@123.45.67.89's password:
[root@centos ~]#

Once in, we’ll navigate to the location of all network configuration for CentOS servers, /etc/sysconfig/network-scripts

[root@centos ~]# cd /etc/sysconfig/network-scripts
[root@centos network-scripts]#

Here, you can see the current configuration for your live connections, such as eth0 found in the ifcfg-eth0 file.

[root@centos network-scripts]# cat ifcfg-eth0
# Virtio Network Device Public Interface
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:00:FF:FF:00:FF
ONBOOT=yes
IPADDR=123.45.67.89
NETMASK=255.255.255.0
GATEWAY=123.45.67.1
DNS1=209.208.127.65
DNS2=209.208.25.18

We’ll be stealing from this configuration for the most part, with some slight alterations. There’ll be a lot less in here for an alias instead of a full-fledged, dedicated interface. The first major change we will see is the naming convention.

While the interface name eth0 is pretty straightforward, adding an alias to that interface will go by a slightly different syntax. In CentOS, alias interface files are used to bind multiple addresses to a single interface. The aliases follow the naming scheme ifcfg-<if-name>:<alias-value>.

Since this is still going on the interface eth0, we’ll start with that, but add a ‘:0‘ to the end, to make eth0:0. We’ll just touch it to create it.

[root@centos network-scripts]# touch ifcfg-eth0:0

If we ever need to add another aliased interface, we’ll simply change the ‘:0‘ to a ‘:1‘ and move on from there. The system will be able to differentiate based on that. We recommend just using numbers when separating these interfaces, but technically they can go by any simple naming convention.

Next, we’ll jump in with our favorite text editor.

[root@centos network-scripts]# nano ifcfg-eth0:0

We will be using the information from the ‘Public IPs’ page to create our new aliased interface. Since this is just an alias, we won’t have to add the gateway or DNS settings since those are determined by the main interface. Additionally, we won’t have to add the MAC address of the NIC.

This just leaves us with the following information to input:

  • DEVICE: Device name, which in this case is eth0:0.
  • BOOTPROTO: Boot protocol. Aliases will always be static, not DHCP.
  • ONBOOT: Whether or not it will come up as active on boot. Normally, this will be yes.
  • IPADDR: The public IP address we just added.
  • NETMASK: The subnet mask of the public IP address we just added.

It should look something like this:

DEVICE=eth0:0
BOOTPROTO=static
ONBOOT=yes
IPADDR=145.67.89.23
NETMASK=255.255.254.0

Once the IP is added, save your settings and exit. We can test our new IP by turning up the interface with the ifup command.

[root@centos network-scripts]# ifup eth0:0

You can check the status of your new alias by running the ip command and the name of the new alias.

[root@centos network-scripts]# ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:00:ff:ff:00:ff brd ff:ff:ff:ff:ff:ff
    inet 123.45.67.89/24 brd 123.45.67.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 145.67.89.23/23 brd 145.67.90.255 scope global secondary eth0:0
       valid_lft forever preferred_lft forever

Alternatively, you can use the ifconfig command if you had the net-tools package previously installed.

[root@centos network-scripts]# ifconfig eth0:0
eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 145.67.89.23  netmask 255.255.254.0  broadcast 145.67.90.255
        ether 00:00:ff:ff:00:ff  txqueuelen 1000  (Ethernet)

Confirm that the IP is responsive by pinging the IP from the server itself or an outside source.

C:\>ping 145.67.89.23

Pinging 145.67.89.23 with 32 bytes of data:
Reply from 145.67.89.23: bytes=32 time<1ms TTL=62
Reply from 145.67.89.23: bytes=32 time<1ms TTL=62
Reply from 145.67.89.23: bytes=32 time<1ms TTL=62
Reply from 145.67.89.23: bytes=32 time<1ms TTL=62

Ping statistics for 145.67.89.23:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

And we’re done!

Troubleshooting an Added IP in CentOS 6.X

Should you still have issues with the newly assigned IP, try one of the few steps below to get the IP working:

  • Bring the interface down and back up with ifdown and ifup:
[root@centos network-scripts]# ifdown eth0:0 && ifup eth0:0
  • Restart your network service via service:
[root@centos network-scripts]# service network restart
  • Double-check that you haven’t added a gateway to the new configuration. A second gateway could cause problems when traffic is exiting the server since it doesn’t have a singular gateway to exit from.
  • Unassign and reassign the IP address in the Atlantic.Net Cloud control panel.
  • If all else fails, release the IP from the Atlantic.Net Cloud control panel and try with a fresh, randomly assigned IP.

Troubleshooting an Added IP in CentOS 7.X

Troubleshooting in CentOS 7.X is largely unchanged from CentOS 6.X, just with the addition of the new service management interface, SystemD (systemctl). You can try these few things if you still have trouble.

  • Bring the interface down and back up with ifdown and ifup:
[root@centos network-scripts]# ifdown eth0:0 && ifup eth0:0
  • Restart your network service via systemctl:
[root@centos network-scripts]# systemctl restart network
  • Double-check that you haven’t added a gateway to the new configuration. A second gateway could cause problems when traffic is exiting the server, since it doesn’t have a singular gateway to exit from.
  • Unassign and reassign the IP address in the Atlantic.Net Cloud control panel.
  • If all else fails, release the IP from the Atlantic.Net Cloud control panel and try with a fresh, randomly assigned IP.

If you have any problems with your new public IP that these troubleshooting steps can’t fix, reach out to our support email at cloudsupport@atlantic.net or our phone line at 888-618-DATA (3282) or int’l: +1-321-206-3730.