ANS Documentation

Improve This Doc
  • Cloud
  • Domains and DNS management
  • Backup and High Availability
  • eCommerce Stacks
  • Security
  • Email
  • Monitoring and usage management
  • Networking
  • Operating systems
    • Linux
      • Basics
      • Apache
      • Control Panels
      • FTP
      • Magento
      • Miscellaneous
      • MySQL
      • NGINX
      • PHP
      • PHP-FPM
      • Setting up Websites
      • NFS
      • VPN
      • Percona
      • SSH
      • SSL
      • Git
      • Redis
      • Elasticsearch
      • MongoDB
      • Ncdu
    • VMware ESXi
    • Windows
  • Webcelerator
  • MyUKFast
  • Home >
  • Operating systems >
  • Linux >
  • Basics >
  • Adding an IP Address

Adding an IP Address¶

Note

You should speak with your account manager to have an IP address assigned to you before adding IPs to your server.

The quickest way to add an IP on either CentOS or Ubuntu would be to use the ip command as follows:

   ip addr add 10.10.10.10/28 brd + dev eth0

That example would add an IP of 10.10.10.10 with a netmask of 255.255.255.240 (CIDR /28) onto the interface eth0.

Although there’s nothing wrong with that command, the IP won’t persist beyond a reboot.

For that, we’ll need to add it the respective network configuration file for our operating system.

CentOS¶

On CentOS 5, 6 and 7, IP addresses are added in files in the following directory:

   /etc/sysconfig/network-scripts

Files should be created with the name ifcfg-ethX and have the following content:

   DEVICE=eth0:1
   ONBOOT=yes
   BOOTPROTO=static
   IPADDR=192.168.0.1
   NETMASK=255.255.255.0

Once you’ve added the your configuration file, bring the interface up with the ifup command:

ifup eth0:1

Ubuntu¶

On Ubuntu, all the network config is typically stored in one file: /etc/network/interfaces

This file should already exist as it’ll have your existing network configuration in place.

Additional IP addresses should be added underneath the existing configuration with the following syntax:

   auto eth0:1
   iface eth0:1 inet static
      address 192.168.0.1
      netmask 255.255.255.0

Again, the interface can be brought up with ifup, as so:

   ifup eth0:1

Next Article > Monitoring performance with atop

  • Useful Links
  • SMB
  • Enterprise
  • Channel
  • Public Sector
  • ANS Data Centres
  • About ANS
  • Careers
  • Blog
  • Get in touch
  •  
  • Sales 0800 458 4545
  • Support 0800 230 0032
  • Get in touch

© ANS Group Limited | Terms and Conditions | Corporate Guidance | Sitemap
ANS Group Limited, registered in England and Wales, company registration number 03176761, registered office 1 Archway, Birley Fields, Manchester M15 5QJ