Debian – static ip, /etc/network/interfaces

debianifconfiginterfacenetworkingstatic-ip

I tried to set a static IP on my Debian 8.1 (in VirtualBox), so I edited the /etc/network/interface file :

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.51
netmask 255.255.255.0
gateway 192.168.1.1
broadcast 192.168.1.255

This configuration seems correct (I also tried without 'auto eth0') and the ip is not already used in the network.

However, when I check with ifconfig, eth0 does not appear, there is obviously an error in my configuration.

ifconfig without interfaces edit (normal) :

eth0      Link encap:Ethernet  HWaddr 08:00:27:4a:58:ae  
          inet addr:192.168.1.43  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe4a:58ae/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:26 errors:0 dropped:0 overruns:0 frame:0
          TX packets:77 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2201 (2.1 KiB)  TX bytes:10924 (10.6 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:39 errors:0 dropped:0 overruns:0 frame:0
          TX packets:39 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4573 (4.4 KiB)  TX bytes:4573 (4.4 KiB)

ifconfig with interfaces edit (abnormal) :

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:39 errors:0 dropped:0 overruns:0 frame:0
          TX packets:39 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4573 (4.4 KiB)  TX bytes:4573 (4.4 KiB)

I would like to know how to configure this eth0 interface to get a static ip.

Best Answer

There might be more in your file (as Safado above notes) that you did not include, and that might be at fault. Is there a header perhaps that you have accidentally pulled onto two lines that is incorrectly formatted?