Skip to content
July 4, 2017 / ftth

Displaying a host IP pre-logon on Arch

Sometimes it’s useful to be able to determine a system’s IP address directly from the terminal, prior to logon.

To do that, you can create a dedicated systemd unit file (e.g. /lib/systemd/system/display_ip_on_logon.service):

[Unit]
Description=Update /etc/issue with ip address
After=network.target

[Service]
ExecStart=/usr/local/bin/update_etc_issue

[Install]
WantedBy=multi-user.target

The script would be pretty straightforward:

#!/bin/bash#
while true
    do IP=$(/sbin/ip route get 1 | cut -d " " -f7)
    printf "ubicast mediacoder $HOSTNAME $IP\n\n" > /etc/issue
    sleep 30
done

That way, when connecting a display to the system, just type any key on the keyboard and the logon banner will show the host IP.

Do not forget to:

systemctl daemon-reload
systemctl enable display_ip_on_logon.service
systemctl start display_ip_on_logon.service

Leave a comment