Set a static IP address in Linux Mint 14

It is not intuitively obvious how to assign Linux Mint 14 a a static IP address from the command line. However, much of Linux administration involves the editing of text files, and assigning a static IP address is no different. You’ll need to edit the following file:

/etc/network/interfaces

Initially, the file only contains information about your local loopback address:

auto lo
iface lo inet loopback

To assign a static IP address, you’ll need to make some changes to this file.

Let’s say you want to assign a static IP of 192.168.1.2 to your eth0 network connection (the first Ethernet adapter on your system; if you only have one, it will be eth0), with a subnet mask of 255.255.255.0 and a local gateway of 192.168.1.1. First, make a backup copy of the interfaces file:

sudo cp /etc/network/interfaces ~

This will make a backup copy in your home directory in case something goes amiss during the editing process. Next, fire up a text editor:

sudo vi /etc/network/interfaces

(Obviously you can substitue emacs or your editor of choice.)

Once the file is open, add the following lines:

iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1

Once you’ve added these lines, save the interfaces file to disk, and exit your text editor.

You’ll then to need have your system load the new IP configuration. You can do that by rebooting, but if that takes too long, you can use this command to force Linux Mint 14 to re-read the configuration files:

sudo ifup eth0

Your system will then have a static IP address.

-JM

/etc/network/interfaces

ADDITIONAL READING:

The Linux Command Line Beginner’s Guide.

The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide.

This entry was posted in Linux Mint 14. Bookmark the permalink.

One Response to Set a static IP address in Linux Mint 14

  1. bob says:

    tried to do this
    firtst remarked that the ¨sudo ifup eth0¨ did not function
    I firts stopped networking by a ¨sudo ifconfig eth0 down¨
    an then the command worked
    After reboot I had no network anymore, so lucky I had a backup copy of the original
    file resulting again in a the default Dynamic IP address

    What did I wrong?

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>