Ubuntu Linux Static IP Configuration

Posted on in Categories , , last updated July 5, 2016

I have an Intel Corporation 80003ES2 LAN Gigabit Ethernet Controller. How do I set a static IP address settings for my Ubuntu Linux server as follows:
DEVICE name : eth0
Type: static
IP ADDRESS : 10.10.29.66
NETMASK : 255.255.255.192
ROUTER IP: 10.10.29.65
Broadcast: 10.10.29.127

How do I setup a static IP address under a Ubuntu Linux 14.04 or 16.04 LTS server?

Ubuntu Linux server stores all network configuration options in /etc/network/interfaces configuration file. You need to open this file using a text editor such as vi or gedit or nano. In this tutorial you will learn how to assign a static IP to Ubuntu server operating system.

How to set a Static IP in Ubuntu Linux

Open the terminal command line application or ssh into remote server. Type the following command:
sudo vi /etc/network/interfaces
OR
sudo nano /etc/network/interfaces
Make the changes as follows:

auto eth0
iface eth0 inet static
 address 10.10.29.66
 netmask 255.255.255.192
 network 10.10.29.65
 broadcast 10.10.29.127
 gateway 10.10.29.65
# Google dns server for our network
 dns-nameservers 8.8.8.8 8.8.4.4

Save and close the file. Restart networking on Ubuntu Linux 14.04 LTS or older:
$ sudo /etc/init.d/networking restart
If you are using systemd based Ubuntu Linux version such as 16.04 LTS or above, enter:
$ sudo systemctl restart networking
Here is another configuration from one of my servers:

Fig.01: Ubuntu static config for eth0 and eth1 with static routing
Fig.01: Ubuntu static config for eth0 and eth1 with static routing

How do I verify a static IP configuration on Ubuntu?

To see new IP address, enter:
$ sudo ip a show
To see new routing table, enter:
$ sudo ip r
Try to ping a network IP or domain name:
$ ping 8.8.8.8
$ ping cyberciti.biz

Verify dns too:
$ host cyberciti.biz
$ dig google.com

A note about enabling an IPv6 static address on Ubuntu

Edit /etc/network/interfaces file, enter:
$ sudo vi /etc/network/interfaces
Append/edit as follows after inet (IPv4) config:

### Start IPV6 static configuration
iface eth0 inet6 static
#pre-up modprobe ipv6
	address 2400:6180:100:d0::7c:c001
	netmask 64
	gateway 2400:6180:100:d0::1
	dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844 8.8.8.8
### END IPV6 configuration

Restart the networking service:
$ sudo systemctl restart networking
Verify it as described here:
# ifconfig eth0
# ip -6 address show eth0
# ping6 google.com

See more Ubuntu Linux networking examples here.

4 comment

  1. Stop using “sudo vi” and use sudoedit instead. There is a shell escape in vi. Using sudoedit blocks that. That’s important if you are not the only user on a system. You can set your EDITOR or VISUAL environment variable to use either /usr/bin/vi or /usr/bin/nano automatically. I can never remember the difference between EDITOR and VISUAL, so I usually set them both to the same editor.

  2. The nameservers 8.8.8.8 and 8.8.4.4 are provided by Google for public use, so you can use them in your network configuration.

Leave a Comment