How to Configure Static IP Address on Ubuntu 16.04

To configure a static IP address on a Ubuntu 16.04 server, you need to access the server as root user or as a sudo user with super user privileges.

Ubuntu 16.04 uses the interface file (/etc/network/interfaces) to configure the network settings.

Before starting changing the network configuration, we need to find the interface name on the server. For that we can use any of the following commands.

# ifconfig -s

# ip link

# netstat -i

From the above results, we can see that the active network interface on the server is eth0.

You can edit the network configuration file (/etc/network/interfaces) by using your favorite editing tool like nano, vim,..etc. Before editing, you should note down the IP address that needs to be added to the server, gateway, subnet mask, and the active interface name. You may define the resolver addresses on the network configuration file so that the nameservers defined on the /etc/resolv.conf file will be replaced with the DNS nameservers given in the network configuration file.

Please see the following example to add a static IP address on the server.

[email protected]:~# vi /etc/network/interfaces

+++++++++++++++++++++++++++++

auto lo

iface lo inet loopback

auto eth0

iface eth0 inet static

address 107.175.91.116

gateway 107.175.91.1

netmask 255.255.255.0

dns-nameservers 8.8.8.8 8.8.4.4

+++++++++++++++++++++++++++++

After adding the details on the /etc/network/interfaces file, you need to restart the network service to apply the changes. To restart the network service, please run the command,

# systemctl restart networking.service

OR

# /etc/init.d/networking restart

Verify that the new IP address has been added successfully by running the “ifconfig” command.

Server Hosting Solutions by RackNerd:

Shared Hosting
cPanel Web Hosting in US, Europe, and Asia datacenters
Logo
Reseller Hosting
Create your new income stream today with a reseller account
Logo
VPS (Virtual Private Server)
Fast and Affordable VPS services - Instantly Deployed
Logo
Dedicated Servers
Bare-metal servers, ideal for the performance-demanding use case.
Logo

Leave a comment

Your email address will not be published. Required fields are marked *