LinuxMoz

Linux Stuff && Coffee

Ubuntu Static IP

| Comments

This guide explains how to assign Ubuntu a static IP address using the command line, this should work on all versions of Ubuntu.

How to set Ubuntu static IP address

There are several ways you configure network setting on Ubuntu, the instructions below will work on all installs including those without a GUI.

To start off with let’s open the file that contains all the network interface information:

1
sudo vi /etc/network/interfaces

(if you need help with Vi, see LinuxMOZ’s Vi Commands Cheat Sheet)

If you on a default install of Ubuntu your network settings will be pulled via DHCP and your file will look similar to:

1
2
3
4
5
6
7
8
9
10
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

Comment the existing info out and add the following Ubuntu static IP address info so it looks like:

1
2
3
4
5
6
7
auto eth0
iface eth0 inet static
address 10.0.0.2
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.1

Obviously replace with your own network settings.

To ensure Ubuntu uses the static IP address restart the network to apply the changes:

1
sudo /etc/init.d/networking restart

`

I would also recommend removing the DHCP client:

1
sudo apt-get remove dhcp-client

If you have found this Ubuntu static IP address tutorial useful then please share using the buttons below.

Comments