3

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 255.255.255.255. I want to set it to 255.255.255.0. 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 255.255.255.0. 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?

Thanks!

  • 1
    DHCPDISCOVER is using wrong netmask: A dhcp client always broadcast on 255.255.255.255 – ripat Nov 14 '13 at 7:09
  • Yes and it broadcasts on the reserved IP of a.b.c.255 – Piotr Kula Feb 17 '14 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 Apr 18 '14 at 20:52
1

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)
netmask 255.255.255.0
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 10.16.25.42 you nano file should look something like this

nameserver 10.16.25.15

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!

0

Try specifying the broadcast address as well.

ifconfig eth0 inet 192.168.1.38 netmask 255.255.255.0 broadcast 192.168.1.255

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? – Arjun Bajaj Nov 13 '13 at 18:17
  • Maybe broadcast 192.168.1.255? 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 Nov 13 '13 at 18:45
  • 1
    @ArjunBajaj Can you please tell me if you got it to working ? – Venkat Sudheer Reddy Aedama Apr 3 '15 at 8:16
-1

Windows machine use a netmask of 255.255.255.0. 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, privacy policy and cookie policy

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