Logo

How to set a static ip address in Ubuntu Server 14.04

Aug 20, 2021

When you install Ubuntu server, its network setting defaults to dynamic IP addressing, that is, the network management daemon in Ubuntu searches for a DHCP server on the connected network and configures the network with the IP address assigned by DHCP. Even when you start an instance in the cloud, the network is configured with dynamic addressing using the DHCP server setup by the cloud service provider. In this chapter, you will learn how to configure the network interface with static IP assignment.

Follow these steps to connect to the network with a static IP:

Step 1 : Get a list of available Ethernet interfaces using the following command

ifconfig -a | grep eth

Step 2 : Open /etc/network/interfaces and find the following lines:

auto eth0
iface eth0 inet dhcp

Step 3 : Change the preceding lines to add an IP address, net mask, and default gateway (replace samples with the respective values):

auto eth0
iface eth0 inet static
     address 192.168.1.110
     netmask 255.255.255.0
     gateway 192.168.1.1
     dns-nameservers 8.8.8.8 8.8.4.4

Step 4 : Use ifdown & ifup to reconfigure desired interface

sudo ifdown eth0 && sudo ifup eth0

Step 5 : Try to ping a remote host to test the network connection

ping www.google.com