Dietpi Banner shows randomly Wlan IP or Eth IP. Would like to see both

The banner is very useful to see what IP addresses has been assigned. But then I noticed the wlan0 IP address is shown and another time the eth0 IP address, randomly.

Using dietpi-banner tool I have solved this by defining my own LAN IP item, using the Custom Entry (option 10).

First I disabled the original “LAN IP” (option 5) and enabled option 10.

Then I choose OK and put in this custom entry command:
echo -e "ETH: $(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}') | WLAN: $(ip -4 addr show wlan0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')"

and named it also:
LAN IP

This solved my problem. Maybe useful for others and/or a future version of Dietpi :slight_smile:

EDIT: I had to enable option 5 again as my Custom Entry is only shown when I SSH login. The banner that is shown on-screen right after booting up only shows option 5 (with the random IP). So the request stays “would like to see both”. Thanks.

Just add your bash line to your ~/.bashrc and every time you log in you will see the message.

Don’t understand this, option 10 is for weather :sweat_smile:, option 5 is only LAN IP.
Or did you mean option 5 of dietpi-banner (which would be for cloudshell??) and option 10 of dietpi-config -> autostart?

What about option 17 in the autostart options (Custom script executed in foreground and auto-login)

the Banner should prefer ethernet over wifi. To have both IP’s displayed, you would need to create a custom entry and add your code there.

did you reboot after banner change? because these are no live data. They are static and updated dring boot, login or if calling dietpi-banner 1

1 Like

Thanks for the quick reply!

My ethernet cable is plugged in and working. I frequently reboot my device and saw the wifi IP instead of the ethernet IP. That’s why I started looking for a fix. I want to see both IPs.

I did not expect that my Custom Entry is not shown on-screen after booting (only after SSH login), so the missing “LAN IP” message now became a problem not knowing the address. So I flipped option 5 back on.
Note: My Custom Entry is rather useless when I already managed to SSH into my device :wink:

You say “the Banner should prefer ethernet over wifi” (which makes sense too) but I have seen different. I shall do some repeated tests (reboots) later today to see if I can reproduce the issue and report back.

Ahh now I understood your request/question. The banner (before login) on the attached physical screen is not managed by dietpi-banner (as far as I know) Would need to check our code where this is coming from.

Exactly! That’s what I meant :slight_smile:
Thanks!

found it.
after boot, the banner on a physical screen is called from /boot/dietpi/postboot. There following is triggered /boot/dietpi/func/dietpi-banner 0 which displays top section + LAN IP.

Information for the used interface will be collected from global function

G_GET_NET -q iface
G_GET_NET -q ip

Means, no real way for an end-user to have it maintained

Yeah I found that code too, in /boot/dietpi/func/dietpi-banner, in function Print_Local_Ip. I was looking into that file first to fix it, but then I recalled the Custom Entry would be the clean way to solve it.

By the way:
I have rebooted my device several times now and it is truly so: sometimes wlan0 IP is shown and sometimes eth0 IP. It’s 50-50.

Thanks for this idea. It didn’t work though as I want to show the result “before login”.

But the earlier post from Joulinar about /boot/dietpi/postboot got me in the right direction.

I placed a script in /var/lib/dietpi/postboot.d/ that prints the IP addresses, surrounded with nice DietPi-green colored horizontal lines :slight_smile:

1 Like

maybe you can share your script. Just if there are other users who are looking for such a “workaround”

Sure!

I created a script named ‘print_both_ipaddresses.sh’ (can be any name) and placed it in /var/lib/dietpi/postboot.d/.

The script looks like this:

#!/bin/bash

GREEN_LINE=" \e[38;5;154m─────────────────────────────────────────────────────\e[0m"

echo -e "$GREEN_LINE"
echo -e "LAN IP: ETH: $(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}') | WLAN: $(ip -4 addr show wlan0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')"
echo -e "$GREEN_LINE"

Since this script will be executed just before /boot/dietpi/func/dietpi-banner 0, the message showing both IP addresses shall appear first, right above the usual “LAN IP”.

:light_bulb:I still use the Custom Entry as well. This in order to see both IP addresses in the banner when I SSH into my device. With this done it makes the option 5 “LAN IP” option superfluous for both cases and so I finally could disable option 5 in dietpi-banner.

1 Like