Ubuntu Server 14.04 Setting a Static IP

With a server that requires port forwarding from the router to the server you will want to either use a DHCP reservation on your router or use a static IP on the server. If you want to use a DHCP reservation Google how to do it for your router. If you want to use a static IP on a Ubuntu Server follow the instructions below.

To set a static ip you’ll need to modify the network interfaces file. To do this type sudo nano /etc/network/interfaces.

The default file is below (you will note that my interfaces file has eth0 and eth1 interfaces, this is because my motherboard has two network adapters. Your interface file will likely only have eth0). We will be changing it from DHCP to static and then specifying our IP address schema.

Default /etc/network/interfaces files

# 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

auto eth1
iface eth1 inet dhcp

To setup a static IP you’ll need to replace dhcp with static and then add lines defining the desired address, netmask, and gateway. Additionally you can define the network and any dns servers you want to use. The full /etc/network/interfaces file for a static IP address is below.

# 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 static
 address 10.13.14.10
 netmask 255.255.255.0
 network 10.13.14.0
 gateway 10.13.14.1
 broadcast 10.13.14.255
 dns-nameserver 8.8.8.8
 dns-nameserver 8.8.4.4
auto eth1
 iface eth1 inet static
 address 10.13.14.11
 netmask 255.255.255.0
 network 10.13.14.0
 gateway 10.13.14.1
 broadcast 10.13.14.255
 dns-nameserver 8.8.8.8
 dns-nameserver 8.8.4.4

Then restart your networking service to apply the changes:
sudo ifdown eth0 && sudo ifup eth0


Leave a Reply

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