Ubuntu Linux Static IP Configuration

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

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
sudo nano /etc/network/interfaces
Make the changes as follows:

auto eth0
iface eth0 inet static
# Google dns server for our network

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
$ 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
### 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.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • John Jun 22, 2009 @ 0:19

    Your missing the DNS entry in /etc/resolv.conf.

    nameserver XXX.XXX.XXX.XXX

  • gitan Apr 3, 2013 @ 9:12

    Nice info .

  • IamJeff Jul 2, 2016 @ 23:43

    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.

  • Linwood Murrufo Jul 31, 2016 @ 20:23

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

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum