Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

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?

share|improve this question

closed as too localized by qbi, Jorge Castro, fossfreedom Dec 18 '12 at 19:49

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Does the output change if you enter ifup eth0? What is the output of ifconfig -a? –  qbi Dec 18 '12 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 '12 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 '12 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 '12 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 '12 at 15:43
show 1 more comment

2 Answers 2

Do not do service networking restart; it is deprecated.

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

share|improve this answer
    
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 '12 at 14:48
add comment

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

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.