Debian - Define a private static IP address

Page 1 / 1
  • Published on : 05 March 2015 at 13:31 UTC
  • By Lionel Eppe

When you install Debian on a machine to use it as a server, it's recommended to set a static IP address for it.

Tested under Debian 7.7.0.

  1. Uninstall the network manager (networkmanager)
  2. Configure the network interfaces manually
  3. Restart the network service to apply the changes

1. Uninstall the network manager (networkmanager)

To set a static IP and make this setting persists address, you MUST remove the installed Debian network manager. This program tends to do everything he can to keep the network connection, even delete your settings and reset your network connection automatically (Assigning the IP address via a DHCP server).

For this program avoids deleting your custom configuration, the easiest way is to remove it :

Code : Bash

apt-get remove network-manager-gnome network-manager

Note : The network icon appear in the top bar has disappeared after uninstalling this program.

 

2. Configure the network interfaces manually

To configure your network interfaces, you must edit the "/etc/networks/interfaces" file.

Code : Bash

vi /etc/network/interfaces

By default, you will find the following lines :
Note : This is the configuration of the network card loopback called "local loop". This information is displayed by the command "ifconfig".

Code : Plain Text

auto lo
iface lo inet loopback

Warning, don't delete these lines.
To configure your network interface (eth0), you must add the following lines :
Notes :
- Leave a blank line to separate the two interfaces.

Code : Plain Text

auto eth0
iface eth0 inet static
address 10.0.0.6
netmask 255.0.0.0
gateway 10.0.0.1

And edit the "/etc/resolv.conf" file for DNS servers :

Code : Bash

vi /etc/resolv.conf

Code : Plain Text

nameserver xx.xx.xx.xx
nameserver xx.xx.xx.xx

Warning : DNS servers listed in the "/etc/resolv.conf" file will be overwritten by those received via DHCP, if you change the interface into "dhcp" instead of "static".

 

3. Restart the network service to apply the changes

Code : Bash

service networking restart

Check the network configuration by typing this :

Code : Bash

ifconfig

If the IP address isn't correct, restart the machine :

Code : Bash

reboot

Now, the IP address and DNS servers are correctly defined.