Second IP Adress on eht0

  • Platform information:
    • Hardware: Raspberry Pi 4 4GB
    • OS: Openhabian / Raspbian 10,7
    • Java Runtime Environment: Zulu OpenJDK 11
    • openHAB version: 3.0.0
  • Issue of the topic: Not really an issue, but why having 2 ip addresses

I use static ip configuration via dhcpcd.conf. But when i look at
ip a
I see that there is a second ip address on eht0.

When i look into syslog, i can see that dhclient is asking for an ip on boot. Where is this configured? Normally i would think it is in
/etc/network/interfaces
But this file is nearly empty, just the include of interfaces.d.

Does anyone of you have an idea?

What is the second io? Is it a valid one for your network?

Yes, i have the static one
192.168.1.8
and then the second one which comes from the DHCP
192.168.1.137

I ran into the same issue.

The problem is Network Manager. I believed this has been installed to provide the hotspot feature. Network Manager itself has a DHCP client, leading to 2 addresses when you put a fixed one in dhcpcd.conf.

I got over this by setting a fixed IP with Network Manager and disabling the dhcpcd service completely.

sudo systemctl disable dhcpcd
sudo nmcli connection show
nmcli connection edit 'Wired connection 1'

And then inside the edit tool:

set ipv4.addresses 192.168.0.11
set ipv4.gateway 192.168.0.1
set ipv4.dns 192.168.0.1 8.8.8.8
set ipv4.method manual
set connection.autoconnect yes
save

My problems got worse when I tried setting up a VPN server with bridging on the same box (SoftEther, but openVPN would be the same). I needed to bridge the network for that with a tap_soft interface. And again, Network Manager played faul. I lost all access to the RPi and had to attached it to a monitor. I was not able to solve it yet and reverted to the included Wireguard. While that works and is easy to set up, it does not allow my UPnP media traffic to pass through.

@mstormi I believe this may have to be investigated further. I am not sure my solution does not create any other issues somewhere else. I need to set a fixed IP and my provider router dus not support ip address reservations. I still think the possibility to set a fixed IP for these cases in openhabian would be useful. With the current solution, we have to derive from the standard way of doing this with Raspberry Pi OS.

2 Likes

Oh, thatā€™s a good example that you sometimes need a second pair of eyes. :smiley:

I was looking like crazy yesterday evening but didnā€™t think about that there could be another process (NetworkManager) who is calling for an DHCPā€¦ :slight_smile:

Iā€™ll give it a shot when iā€™m at home!

Thanks a lot!

Feel free to.

I do not. And in either case this would be overly complicating all the setup code let alone that most of this originates from Raspi OS or whatever OS you install openHABian on.
So doing the math upfront, the projected efforts to get this working as well as chances to break anything else at the same time are both very high. Benefit on the other hand side there isnā€™t any, itā€™s rather the opposite: more ways to configure OSs just lead to more errors and more need for support.
Anyone who dislikes it is free to change it on his box or to stop using openHABian for this purpose.

@mstormi I understand your point of view. I also very much appreciate all the effort you have put in openhabian. Openhabian makes a world of difference in getting openHAB up and running on a RaspberryPi.

My feedback was meant to be constructive. Introducing the hotspot feature has unexpected side effects that break basic Raspi OS features. If you donā€™t consider this relevant, I still hope that my documenting this helps other people to avoid the time I spent to understand whatā€™s happening.

With the introduction of the hotspot feature, Network Manager has been installed. This is not part of a standard Raspi OS install. Network Manager conflicts with the standard way of configuring the network in a Raspi OS, using dhcpcd.conf. Because of this, the RPi will ask for a DHCP lease twice during startup, once triggered by Network Manager, once by the standard process. It of course gets the same address twice.
Standard Debian avoids this by automatically disabling Network Manager for any interface defined in /etc/network/interfaces. In standard Debian, thatā€™s the place where the eth0 wired interface is normally defined. However Raspi OS does things differently with Buster, and does not have anything in that file anymore. Openhabian even excplicitly makes it empty. So the wired interface become managed, like the wireless one (as is the intention for the hotspot feature). Therefore Network Manager also requests an IP address from the DHCP server.

Setting a fixed IP in dhcpcd.conf (the recommended way for Raspi OS) is nothing more than telling the DHCP server to get this static address. The same is true for setting it in Network Manager (as shown in my previous message). But not doing it in both places, or disabling one of the services, would lead to 2 different IP addresses.
FWIW, I did try to add eth0 back the the /etc/network/interfaces file, but it did not help. The wired connection was still managed by Network Manager, and the dhcpcd configuration was not respected.

I suggest you experiment with this:
The openHABian code to get executed on install/boot is here.
Try moving the installation of network manager before those two places where the hotspot gets installed.
Iā€™m too tired to spend more work on the hotspot, it was an enormous effort. But I would take a PR if you ensure openHABian keeps doing what it did before in the various install variants (ethernet exist | wifi ssid empty | static wifi credentials wrong | static wifi credentials correct).

FYI

@mstormi A big thank you for this. I was intending to contribute the change after testing, but you beat me to it.
I have seen all the amazing work you have done with including the hotspot feature and appreciate it was not easy. It isnā€™t very useful for me, but I am sure it is for other people.
Great work.