Why does FireMotD report the wrong IP address?

  • Platform information:
    • Hardware: Raspberry Pi 3
    • OS: Raspbian Stretch (OpenHABian V1.4)
    • openHAB version: 2.2
  • Issue of the topic: FireMotD does not report the same IP address as ifconfig

This is a fresh installation of OpenHab using OpenHABian V1.4. Everything with regards to OpenHAB is working properly.

Upon installation, the Pi was automatically assigned an IP address via DHCP: 192.168.1.115

I changed the host name and set a static IP address (not a static IP lease) using the instructions here:
https://www.modmypi.com/blog/how-to-give-your-raspberry-pi-a-static-ip-address-update
I also updated the DNS (I’m using Pi-Hole) so it knows the Pi’s new hostname and static IP address.

The Pi can now be pinged via its new hostname (ohpi) or its new static IP address (192.168.1.10). I can access OpenHAB’s admin interface using either http://ohpi:8080 or http://192.168.1.10:8080. Perfect!

However, FireMotD continues to report the Pi’s IP address is the old one: 192.168.1.115. Why?

openhab - FireMotD IP Address

On line 223 of /opt/FireMotD/FireMotD there’s script to determine the IP address. The relevant portion is this:
/sbin/ip route get 8.8.8.8 | head -1 | awk -F' ' '{print $(NF)}'
When executed, the command correctly reports 192.168.1.10 and not 192.168.1.115. So why is FireMotD reporting the old IP address?

Hi,

How long have you been waiting since you changed your IP Address? I did the same when I installed my openhab and as you, FireMotD didn’t show the right IP address. After some research I found out that FireMotD runs once per day (between 12:00 and 06:00 if I recall properly) and updates its logs. If you login BEFORE FireMotD runs, it will report false information.

If you wanna update that information right now, execute the following command:

/opt/FireMotD/FireMotD –S

This command will update its internal log file (that you can find at /var/tmp/FireMotD.json) and the information displayed will be the right one.

Hope this helps.

1 Like

@dcalvo
Thank you for your reply. Unfortunately the suggested solution (update information with /opt/FireMotD/FireMotD -S) did not correct the problem.

[18:19:30] openhabian@ohpi:~$ /opt/FireMotD/FireMotD –S
/opt/FireMotD/FireMotD: line 1850: break: only meaningful in a `for', `while', or `until' loop

OK, I don’t know why it produced that response but it did. Anyway, I then ran FireMotD (without -S) and it reported the old IP address:

[18:21:17] openhabian@ohpi:~$ /opt/FireMotD/FireMotD --theme gray
###############################################################################
################# ohpi ############################################ 9.01.180106
###############################################################################
##             Ip = 192.168.1.115
##        Release = Raspbian GNU/Linux 9 (stretch)

– EDIT –
My apologies it appears you were correct! I ran it again but this time with sudo FireMotD and it definitely updated its JSON file with the new IP address. Thank you!

[18:48:03] openhabian@ohpi:~$ sudo /opt/FireMotD/FireMotD -S
[18:48:16] openhabian@ohpi:~$ cat /var/tmp/FireMotD.json
{
  "HostName": {
    "Generated": "@logon",
    "Value": "ohpi",
    "LastRun": "2018-01-21 18:21:23,927"
  },
  "HostIp": {
    "Generated": "@cron",
    "Value": "192.168.1.10",
    "LastRun": "2018-01-21 18:48:07,692"
  },
  "Release": {
    "Generated": "@cron",
    "Value": "Raspbian GNU/Linux 9 (stretch)",
    "LastRun": "2018-01-21 18:48:07,770"
  },

What a relief!! That was the key.

Try to check

/etc/cron.d/firemotd

In that file you will find how often FireMotD is run. In my case, I have:

#FireMotD system updates check (randomly execute between 0:00:00 and 5:59:59)
0 0 * * * root perl -e ‘sleep int(rand(21600))’ && /bin/bash /opt/FireMotD/FireMotD -S &>/dev/null

With that information at hand, you know how much (max) time you will have to wait until its next update (for future changes).

Thank you

Yes, that’s the same as what I have in my /etc/cron.d/firemotd. I changed the IP address late in the afternoon so, as you explained, FireMotD would not detect my modification until its next update after midnight (or if I run it manually with the -S option).

Thanks again, I’ve marked your response as the solution.