I’ve recently had to manually assign a static IP address on one of the servers I manage, here is how I did it:
debian:~# vim /etc/network/interfaces
Inside the file I placed:
# The primary network interfaceallow-hotplug eth0iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0
broadcast 192.168.0.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220
The broadcast and gateway configuration lines are not obligitory.
dns-nameserverswould re-create /etc/resolv.conf file with the nameserver values specified which in these case are Google Public DNS servers and OpenDNS servers.
Very important variable is allow-hotplug eth0
If these variable with eth0lan interface is omitted or missing (due to some some weird reason), the result would be the output you see from the command below:
debian:~# /etc/init.d/networking restart
Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces ... (warning).
Reconfiguring network interfaces...
Besides the /etc/init.d/networking restart is deprecated because it may not enable again some interfaces … (warning)., if the allow-hotplug eth0variable is omitted the eth0 interface would not be brough up on next server boot or via the networking start/stop/restart init script.
My first reaction when I saw the message was that probably I’ll have to use invoke-rc.d, e.g.:debian:~# invoke-rc.d networking restart
Running invoke-rc.d networking restart is deprecated because it may not enable again some interfaces ... (warning).
However as you see from above’s command output, running invoke-rc.d helped neither.
I was quite surprised with the inability to bring my network up for a while with the networkinginit script.
Interestingly using the command:
debian:~# ifup eth0
was able to succesfully bring up the network interface, whether still invoke-rc.d networking startfailed.
After some wondering I finally figured out that the eth0 was not brought up by networking init script, because auto eth0or allow-hotplug eth0(which by the way are completely interchangable variables) were missing.
I added allow-hotplug eth0and afterwards the networking script worked like a charm