3

I would like to connect my pc and my raspbian through a network without internet output.

I have a router with the dhcp disabled, and I connect to this router my raspberry pi 2 and my pc. The pc picks good the interfaces configuration, but raspberry pi is doing weird things.

eth0      Link encap:Ethernet  HWaddr b8:27:eb:91:1d:60  
          inet addr:169.254.252.195  Bcast:169.254.255.255  Mask:255.255.0.0
          inet6 addr: fe80::a05c:8c24:cad8:6a3f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:212 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2280 (2.2 KiB)  TX bytes:50845 (49.6 KiB)

This is the configuration of the interface eth0. I have this in my /etc/network/interfaces

allow-hotplug eth0
iface eth0 inet static
        address 192.168.3.10
        netmask 255.255.255.0

The ip of the router is 192.168.3.1, and netmask is 255.255.255.0. What I'm doing wrong?

2
  • Is the behavior any different if you replace allow-hotplug with auto? I don't know if the kernel delivers a hotplug event for the ethernet interface...
    – larsks
    Commented Feb 9, 2016 at 23:21
  • 1
    Possibly related raspberrypi.stackexchange.com/q/37471/34558
    – techraf
    Commented Feb 10, 2016 at 2:48

3 Answers 3

6

Warning! For this to work properly dhcpcd needs to be disabled. See How do I set up networking/WiFi/Static IP

Don't be lazy. Configure it completely.

auto eth0                      #add this line
allow-hotplug eth0
iface eth0 inet static
        address 192.168.3.10
        netmask 255.255.255.0
        gateway 192.168.3.1
        network 192.168.3.0
        broadcast 192.168.3.255
2
  • 1
    Maybe he's not lazy... My raspberry images, tripi and raspbian so far, just didn't had that line. Thanks for pointing it out.
    – Saiyine
    Commented Apr 17, 2016 at 15:40
  • @Saiyine That line is part of the "Configure it completely" statement :)
    – Aloha
    Commented Apr 18, 2016 at 11:18
2

It is likely that you are running a DHCP client. This attempts to get an IP address for your network interface, gateway address and nameservers for your DHCP server. This is over-riding what you have configured in your /etc/network/interfaces definition. The solution is to edit the /etc/dhcpcd.conf file and add static definitions for your named interface in there. See the man page for dhcpcd.conf for details and/or google for further examples of folks having configured Raspbian and DHCP client. For example:

http://sizious.com/2015/08/28/setting-a-static-ip-on-raspberry-pi-on-raspbian-20150505/

2

Raspbian does not "ignore" /etc/network/interfaces but the file you listed WILL NOT set a static address, dhcpcd will still try to allocate an address.

addr:169.254.252.195 is a link-local address so for some reason this has not happened.

See How do I set up networking/WiFi/Static IP for a tutorial on how to correctly configure networking.

Alternatively you can disable dhcpcd.

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.