Static IP in Ubuntu

Sean Wragg
Mar 18, 2008 · 1 min read

This tutorial is for anyone who wants to use a static ip instead of dhcp. Let’s face it, having a server using dhcp is a bad idea.

First we need to edit /etc/network/interfaces

$ sudo nano /etc/network/interfaces

Typically if you’re using dhcp, your file would look something like the below. Keep in mind the interfaces may be different. For example if you’re using wireless you may see wlan0 or ath0; we’re primarily just looking for the interface you want to change

# 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

In this case, we want to change eth0. Simply change dhcp to static and append some additional network info.

We’re going to need the IP address of that we want to use, the network mask which is typically, the network id, broadcast ip, and your gateway – which is typically your router's IP. All of which can be found using any other machine on your network: using ipconfig /all on any windows box or ifconfig on any *nix machine.

auto eth0  
iface eth0 inet static

Once you’ve made the proper changes and saved the file, can you either reboot or restart your nic

sudo /etc/init.d/networking restart

Originally published at on March 18, 2008.


Code, Comics, and Fhqwhgads!

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store