How to automatically configure eth0 interface after Raspberry Pi is switched on

Mar 31, 2015 5 Replies

Hi,



In my Raspberry Pi based systems using the Buildroot built Linux image I always had problems with eth0 not being correctly configured after switching on. Even if I configured it in the /etc/network/interfaces:



auto eth0 iface eth0 inet dhcp



Or when I called the "udhcpc eth0" from the init scripts.



The reason was, that the USB subsystem was not initialized yet, when the init scripts were executed.



I finally solved the problem using the udev, to configured eth0 as soon as it gets visible. If somebody wants to configure eth0 via DHCP, it may be enough to add the following to the /etc/udev/rules.d/60-rpi-eth.rules rule:



KERNEL=="eth*", SUBSYSTEM=="net", ACTION=="add", RUN+="/sbin/udhcpc $env{INTERFACE}"



If somebody wants to configure the eth0 according to definitions stored in /etc/network/interfaces, then the appropriate /etc/udev/rules.d/60-rpi-eth.rules rule file is:



KERNEL=="eth*", SUBSYSTEM=="net", ACTION=="add", RUN+="/sbin/ifup $env{INTERFACE}"


Regards, Wojciech M. Zabolotny

Hi,

If "udev" is too big for your system, and you decide to use "mdev" to dynamically manage devices, the working solution is to add:

#network interface (eth.*) root:netdev 660 >net/%1 @/sbin/ifup $INTERFACE

at the end of the /etc/mdev.conf file.

Regards, Wojciech M. Zabolotny

[]

Why not download and use Raspbian? I haven't been aware of the problem using the downloadable versions.

Cheers, David Web: http://www.satsignal.eu

Raspbian is very huge. Additionally when using Buildroot compiled Linux I c an run it from initramfs so it:

1) does not wear my SD card 2) it is fully resistant to random power cuts Both features are very good for a system which is supposed to run unattende d for a long time.
Regards, Wojtek

On 01/04/2015 19:10, wzab wrote: []

Whilst I don't see size as a significant problem these days, I can appreciate that both the advantages you cite are genuine benefits. Perhaps one day Raspbian will support initramfs as well.

Thanks for the update.

Cheers, David Web: http://www.satsignal.eu

it does if you use a raspbian kernel instead of the foundation kernel that the foundation bolts onto the raspian image they create.

gregor

-- .''`. Homepage:

formatting link
- OpenPGP key 0xBB3A68018649AA06 : :' : Debian GNU/Linux user, admin, and developer -
formatting link
`. `' Member of VIBE!AT & SPI, fellow of the Free Software Foundation Europe `- NP: Treibhaus: Yellowman Jamaica

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required