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?

6
  • 1
    Does the output change if you enter ifup eth0? What is the output of ifconfig -a?
    – qbi
    Dec 18, 2012 at 6:37
  • @qbi - ifup eth0 gives Error: an inet prefix is expected rather than "192.168.1.37/255.255.255.0". and ifconfig -a shows all devices (eth0 lo wlan0) except the "inet addr" and "inet6 addr" lines are missing from all but the loopback block. Also the wlan0 block has zeroes in the RX and TX areas, since i have it switched off.
    – noobcakes
    Dec 18, 2012 at 15:15
  • Oh, forgot to ask: How do you set those values, i.e. which file do you open or which GUI program do you use?
    – qbi
    Dec 18, 2012 at 15:27
  • No gui installed. I've been editing the /etc/network/interfaces file directly with nano. I work at the console on my laptop for networking stuff and ssh in from my desktop for other stuff.
    – noobcakes
    Dec 18, 2012 at 15:33
  • In your original question you write netmask 225.225.225.0. Is the 225 a typo? It seems strange for a netmask.
    – qbi
    Dec 18, 2012 at 15:43

2 Answers 2

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

2
  • 2
    it is so easy to look at these numbers, and think they are reasonable.
    – Hack Saw
    Nov 24, 2015 at 21:53
  • 2
    This is a very common error, and difficult to spot. Our eyes see what we expect to see.
    – dr_
    Jan 14, 2016 at 8:24
-2

Do not do service networking restart; it is deprecated.

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

2
  • 2
    Those do not solve my problem. I also didn't know the service reset was deprecated; i was using /etc/init.d/networking restart before, and my system told me to use service networking restart instead
    – noobcakes
    Dec 18, 2012 at 14:48
  • Yikes, I always thought reboots are the bane of any Linux aficionado? After all it's why we shun those Windows folks, isn't it? Aug 18, 2020 at 22:22

Not the answer you're looking for? Browse other questions tagged .