Setting Up Static IP Address

RHEL / CentOS / Fedora

Let’s start with the first file:

nano /etc/sysconfig/network

Replace, YOUR_HOSTNAME_HERE with your hostname and IP_GATEWAY with the Gateway IP Address which can be found at our control panel,

NETWORKING=yes
HOSTNAME=YOUR_HOSTNAME_HERE
GATEWAY=IP_GATEWAY
NETWORKING_IPV6=no
IPV6INIT=no

Next edit,

nano /etc/sysconfig/network-scripts/ifcfg-eth0

In that file make the following changes, Leave, UUID and HWADDR as-is,

DEVICE="eth0"
BOOTPROTO="static"
DNS1="8.8.8.8"
DNS2="8.8.4.4"
GATEWAY="IP_GATEWAY"
IPADDR="VPS_MAIN_IP"
NETMASK="IP_NETMASK"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"

Next edit resolve.conf,

nano /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4

Once you have made your changes restart the networking with:

service network restart

Debian / Ubuntu

To setup static IP address in Debian/ Ubuntu, open the following file:

nano /etc/network/interfaces

You may see a line looking like this:

auto eth0
iface eth0 inet dhcp

Change it so it looks like this:

auto eth0
iface eth0 inet static 
address VPS_MAIN_IP
netmask IP_NETMASK
gateway IP_GATEWAY
dns-nameservers 8.8.8.8
dns-nameservers 8.8.4.4

Next, Edit /etc/resolv.conf,

nano /etc/resolv.conf
nameserver 8.8.8.8 
nameserver 8.8.4.4

Restart your networking service,

service networking restart

Last modified: August 24 2017 23:48:05