openHABian setup fails due to ipv6

Just starting with openhabian and bumped on this problem too: FAIL Failed to start /etc/rc.local Compatibility
Allthough it seemed the same, until I read the first-boot log which said
"Ensuring network connectivity … FAILED.
Problem: It doesn’t get an ipv4 address appearantly. Ifconfig does not show an ipv4 address it does give an ipv6 address. This problem I allways have when starting Raspbian for the first time I guess since Jesse already.
So what I did was change /etc/network/interfaces:
-comment everything out
-add

auto eth0
iface etho inet dhcp

and save this. Then use the following commands:

sudo service dhcpcd stop
sudo systemctl disable dhcpcd
reboot

and everything is installed correctly (taking another 30 minutes or so.

Well as an info to all to see this, that’s a little misleading.
It’s a well known error message (with a known cause) but has no link to the reason for setup to fail.

This one is interesting. We have seen it with a very small number of users.
As openHABian doesn’t mess with this part, it’s plain unchanged doing what it does in Raspbian.
What OS+HW are you using ? The Pi image ?
What routing setup do you use, does it somehow promote ipv6 over ipv4 ? Does your Internet Service Provider do? which one?

So the `Failed to start /etc/rc.local Compatibility’ error was the first I saw, because it lights up in red “FAIL”. Then I searched and found the topic I posted this message in.

Now you ask a lot of questions which I will try to answer, but I am not an IT guy, so bare with me.
I use Raspbian Buster on a RPI 3B+.and in this case Openhabian image
openhabian-pi-raspbian-201908050414-gitca0976f-crc6a66b5a1.img
On my Ziggo router I have reserved an ipnr for this mac address. My service provider still supports ipv4 and so I have got an external IPv4 address, and all my other devices have next to a ipv6 also a ipv4 internal address 192.168.x.x. If that is what you asked.

The thing is only Raspbian seems to have this problem. Last week I installed Home Assistant (HAssOS, based on ResinOS), and every thing went fine (installation-wise and network, also over ipv4).

I have been looking for a solution for this problem I have with Raspbian for a long time. But the only way I can solve it right now is like I showed.

Could you please check if https://raspberrypi.stackexchange.com/questions/23884/force-ipv4-address
fixes your general Raspbian problem ? If so we could put it into openHABian. Thanks.

Markus, Thanks for helping me here. Just to be sure:
I create file
/etc/sysctl.d/local.conf
and add the line

net.ipv6.conf.all.disable_ipv6=1

And do that right after the firtst time boot of openhabian has failed and then reboot?

Yes.
The ideal way would be to do that before first boot like this:
Attach USB reader to RPi and insert another freshly flashed SD, sudo fdisk -l to find the device name sdX, then mount /dev/sdX2 /mnt then edit /mnt/etc/sysctl.d/local.conf, finally umount /mnt, then boot from that other SD.
But if you can’t make it, it’s fine if you just do what you described yourself.

Disabling IPv6 altogether is not a solution but more like a workaround if all other devices in your lan works as expected. Can you provide the IPv6 address your device gets?

Agree, but how do you propose we shall handle the general case inside openHABian ?
Even if you did find a solution in this case (correct ipv6 routing or whatever), that wouldn’t be applicable as a general solution

By general case do you mean problem with rc.local? As soon as I get home and have some spare time I’ll take a look.

No, but if you’re willing/able to solve that, too, you’re welcome :slight_smile: . Mind #828 and the work in #844 though.

No by “general” I mean what to change or configure in openHABian by default so it works to get the installation done in as many use cases as possible, including all IPv4 environments but also some (partial?) IPv6 ones. Note there’s no means to interact with the user at that stage.

EDIT: working on a patch to disable ipv6 before boot via a setting in openhabian.conf

So I did add the disable ipv6 line in the newly made local.conf file on the mounted freshly flashed SD, like you pointed out. saved it, umounted it and booted from this SD. But unfortunately the first-boot process failed again on Ensuring network connectivity.

could you please try again and edit /etc/sysctl.conf (or actually /etc/sysctl.d/99-sysctl.conf where that links to). There’s also a number of ipv6 related parameters you can try setting/disabling.
Also make sure you don’t mess up the file (UNIX/DOS linefeed problem, typically).

I get two 2001: global adresses (64 and 128 prefixlen) and one fe80: local address prefixlen 64 on eth0.
BUT when I look in my modem/router I see a different 2001: address for the openhab rpi. The address is in the range of the router though.

I did uncomment all net.ipv6 lines in 99-sysctl.conf, But it makes no difference.

and no ipv4 ?
Mind you this is not supposed to work over IPv6. The IPv6 functionality is just expected to not disturb service on IPv4 level. So if you did switch off ipv6 which you did it should work based on IPv4 unless you have a bad setup for that, too.
Does your DHCP server assign a v6 address ? It should not be giving one provided the linked answer above is correct (and there’s people to confirm it works on buster which current openHABian is based on).

I get confused here…

No, when disable ipv6 by net.ipv6.conf.all.disable_ipv6=1 I do not get a ipv6 address from the DHCP server. But when I start without modifications to the image I see different ipv6 addresses getting from ifconfig and the list on the router.

Right, that’s how it should be.
My open question is: do you get an ipv4 in this case ? Does openhabian installation proceed based on that ipv4 ?

No none at all. No ipv4 address,.

Oh, ok. Then it’s no wonder that openhabian install fails. We of course need at least one working IP address.
Or was that caused by our change, i.e. do you get an IPv4 (and an IPv6) if you use the unchanged image ?

So this is about missing IPv4 connectivity. Title is kind of misleading then. I would revert all configs to default and review your DHCP server settings.