Can ethernet be used for both direct connect and network access?

Can ethernet be used for both direct connect and network access?

  • A Raspberry Pi will by default connect to the network if the ethernet connector is plugged in to a router. It is also possible to configure networking on a Raspberry Pi to direct connect to a computer so no router is necessary. Is it possible to detect which type of setup is present at boot, and make the proper configuration dynamically? I would like to do this to be able to have both a configuration mode (eth0 direct connect with local web server hosting config app) and a normal mode (eth0 internet connection). I have thought about attempting to get a network DHCP lease on eth0, and if it fails, then running a local DHCP server with isc-dhcp-server to let the directly connected computer get an IP address from the Raspberry Pi. Two problems with my solution: It is going to add a lot of delay before the admin page is available. If the Pi is connected to a network at boot, and the network's DHCP server is temporarily down, the Pi will boot into the wrong mode. Is there any simpler, faster and more foolproof way of detecting this?

  • Answer:

    By default, this already happens with link-local addresses. By simply not having a DHCP Server on the network, the Pi will give itself a 169.254.x.x IP address (assuming you're using Raspbian). Any other computer on the network will also have a 169.254.x.x IP address (if they're using a sensible OS). Then the 2 devices can talk using their IP Addresses of 169.254.x.x More information can be found in http://tools.ietf.org/html/rfc3927

davidgyoung at Raspberry Pi Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.