Jump to content

  •  

Photo
- - - - -

How to Set a Static IP Address on Ubuntu and Debian

Ubuntu 12.04 Debian 6

  • Please log in to reply
No replies to this topic

#1 Wilson18

Wilson18

    Administrator

  • root
  • 112 posts
  • LocationUniversity of Birmingham

Posted 25 May 2014 - 11:11 AM

When using a server a server a lot  it is always a good idea to give it a static IP address so we know where to look for it on another machine. We do this by editing our network config file by typing:


nano /etc/network/interfaces

When you open this file, it should look like as follows:

debian_interfaces.png

When you open this file, you will first need to delete the following lines:


allow-hotplug eth0
iface eth0 inet dhcp

You will need to remove the two lines and replace with the following lines. (I will be adding my network configuration so

auto eth0
iface eth0 inet static
    address 10.0.0.150
    netmask 255.255.255.0
    gateway 10.0.0.1

Once completed, it should look like this:

debian_interfaces_completed.png

make sure that the one you enter fits your network setup and that the information is available on your network). When you have done this, you will need to save the file (With Ctrl + O) and exit the file (With Ctrl + X)
The next thing we need to do is set the DNS Servers. We do this by editing the following folder:

nano /etc/resolv.conf

This file should be blank. You will need to add the following content.

nameserver 8.8.8.8
nameserver 8.8.4.4

debian_resolv.png

Now, I would recommend rebooting so that changes can be taken in to affect. When you log back in, you can run the following to view your network information.


ifconfig

debian_ifconfig.png


List what you read?

Check me out on: YouTube, Twitter, Facebook, Google+






Also tagged with one or more of these keywords: Ubuntu 12.04, Debian 6