The Ethernet connection on my RaspberryPi isn't working. After doing some research on StackExchange and other sites, I found the netmask to be the cause of the problem.

When I run ifup eth0, it's using the wrong netmask I want to set it to I can confirm that this is my setting, because my laptop is using the same netmask.

This question describes the same problem, and the solution to that is to run the command sudo ifconfig eth0 192.168.1.X netmask I tried running this command but I get the error host name lookup failure. When I changed the X in the IP Address to a number, the command completes, but it still didn't work.

So is there any other way to change the netmask so that ifup eth0 uses the correct one?


  • 1
    DHCPDISCOVER is using wrong netmask: A dhcp client always broadcast on
    – ripat
    Commented Nov 14, 2013 at 7:09
  • Yes and it broadcasts on the reserved IP of a.b.c.255
    – Piotr Kula
    Commented Feb 17, 2014 at 16:19
  • Can you post your /etc/network/interfaces file on pastebin.com? It sounds like the netmask is getting set incorrectly somewhere...
    – Fred
    Commented Apr 18, 2014 at 20:52

3 Answers 3


Setting up the Netmask

Your IP address, netmask and gateway are all controlled from a single file /etc/network/interfacesit should by default look like this:

iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Change it to look like this:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address (your ip address)
gateway (your gateway)
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

You can get further details to the above procedure here. Just scroll down to the setting up via text part.

DNS Settings

In your command prompt just type in nano /etc/resolv.conf a file should open up which will have your nameservers (DNS settings) listed. Change them to your settings, so for example if your DNS settings are you nano file should look something like this


You can get more details to this here

Verifying if the Settings are Enabled

Reset your network settings or reboot your Pi and then type in sudo ifconfig into your terminal to verify if the settings you've entered are active.

Hope this helps!


Try specifying the broadcast address as well.

ifconfig eth0 inet netmask broadcast

Also a host name lookup failure could be DNS related as well so check your DNS settings are correct.

  • 1
    I tried it, it didn't work. Although I have setup a static IP for Wifi right now, I would like if the Ethernet also works. How should I check the DNS settings? Commented Nov 13, 2013 at 18:17
  • Maybe broadcast To check what your nameservers are you can cat /etc/resolv.conf another thing you can do is try route -n to make sure you have the right gateway and whatnot
    – p1l0t
    Commented Nov 13, 2013 at 18:45
  • 1
    @ArjunBajaj Can you please tell me if you got it to working ? Commented Apr 3, 2015 at 8:16

Windows machine use a netmask of I think the problem is running Windows machines on the same network as the Rpi.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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