Reading Time: 2minutes
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 interface
iface eth0 inet staticaddress 192.168.0.2netmask 255.255.255.0broadcast 192.168.0.0gateway 192.168.0.1dns-nameservers 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206
The broadcast and gateway configuration lines are not obligitory.
dns-nameservers would 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 eth0 lan 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 eth0 variable 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 networking init script.
Interestingly using the command:
debian:~# ifup eth0
was able to succesfully bring up the network interface, whether still invoke-rc.d networking start failed.
After some wondering I finally figured out that the eth0 was not brought up by networking init script, because auto eth0 or allow-hotplug eth0 (which by the way are completely interchangable variables) were missing.
I added allow-hotplug eth0 and afterwards the networking script worked like a charm 😉
More helpful Articles
Tags: Auto, broadcast, configure, debian gnu, DNS, dns nameservers, etc network, eth, file, gateway, GNU, google, inet, init, interfacesInside, lan interface, Linux, nameserver, nbsp, nbsp nbsp nbsp nbsp nbsp, Netmask, network interface, network interfaces, Networking, OpenDNS, public dns servers, reason, resolv, script, server boot, Start, static address, static ip address, vim, weird reason