Search code examples
c#linuxembedded-linuxconnman

eth0 interface doesn't connect if the cable is plugged after the boot


I have a C# .net application running in my own embedded custom linux distro generated by buildroot tool, my hardware is a FriendlyArm4412. I use eth0 interfaces to connect my application to the internet without any problem. The problem is: If I connect the ethernet cable before the system boot everything is OK but if I plug the cable after the system boot my system can't get an ip address. I see this because my application shows on the screen "ip address: 127.0.0.1" which is just my local address.

I've already tried to use the Connman network manager which worked very well for the problem above, but I realized that connman ignores my /etc/network/interfaces settings which is bad because my application sets up some things in this file, like static ip address, wlan0 interface, etc.

What can I do ? Any idea ?


Solution

  • Check DefaultAutoConnectTechnologies configuration parameter in /etc/connman/main.conf file. See whether ethernet is present or not.

    Connman doesn't use /etc/network/interfaces file. You need to use Connman D-Bus API's to set static IP to your network interface. Download Connman source code and see doc/service-api.txt for D-Bus API. Also see test/set-ipv4-method python script in source directory for a quick code reference on how to set static IP using D-Bus API.

    If you don't want to use D-Bus API, you can edit connman storage directory files to set static IP before connman start. But editing connman storage directory is not a right way to do this. Default Connman storage directory is /var/lib/connman/ethernet_$mac_address_cable/*.