9

For some reason, if I try to set a static IP address, my eth0 disappears from ifconfig's output. I am running Ubuntu server 12.10 on a gateway laptop.

auto eth0
iface eth0 inet dhcp

It then gives this output when I run ifconfig:

eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx  
          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::2e0:b8ff:fee7:f71c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:281 errors:0 dropped:0 overruns:0 frame:0
          TX packets:352 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:31874 (31.8 KB)  TX bytes:45369 (45.3 KB)

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:16436  Metric:1
          RX packets:430 errors:0 dropped:0 overruns:0 frame:0
          TX packets:430 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:41740 (41.7 KB)  TX bytes:41740 (41.7 KB)

When I change to static:

auto eth0
iface eth0 inet static
       address 192.168.1.37
       netmask 225.225.225.0
       gateway 192.168.1.1

...then run a service networking restart, I only get the loopback block from ifconfig:

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:16436  Metric:1
          RX packets:430 errors:0 dropped:0 overruns:0 frame:0
          TX packets:430 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:41740 (41.7 KB)  TX bytes:41740 (41.7 KB)

However, I can force a static IP with ifconfig eth0 192.168.1.37 netmask 255.255.255.0 but obviously this goes away on a reboot.

Why will one way work but not the other? Am I doing something wrong?

Eliah Kagan
  • 119,640
noobcakes
  • 191

2 Answers2

10

It was a typo. I should have had 255.255.255.0 as my netmask and instead typed 225.225.225.0

Thanks to qbi for helping me see the error of my ways

noobcakes
  • 191
-2

Do not do service networking restart; it is deprecated.

Instead do ifdown eth0 and then ifup eth0 or simply reboot.

jdthood
  • 12,625