Project

General

Profile

Feature #911

Add IP Address to Pre-Login Console Text on FreeBSD

Added by Daniel Curtis almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
SSH Server
Target version:
Start date:
10/05/2017
Due date:
% Done:

100%

Estimated time:
0.50 h
Spent time:

Description

I recently wanted to add the IP address of my development FreeBSD VMs to the console pre-login prompt, sparing me the time of logging in just to ifconfig once so I can ssh into the VM. Unfortunately FreeBSD does not use /etc/issues like its Linux counterparts, but relies on /etc/gettytab and uses /etc/issue as a shim for text without the use of any macros.

This is how I added the IP address of my machine to the pre-login console prompt on FreeBSD 11.

update-issue script

  • Create an update-issue script:
    vi /usr/local/etc/rc.d/update-issue
    
    • And add the following:
      #!/bin/sh
      
      # PROVIDE: update-issue
      # REQUIRE: NETWORKING syslogd
      # KEYWORD:
      
      . /etc/rc.subr
      
      IPADDRESSESV4=$(ifconfig em0 | grep inet | awk '{print $2}')
      
      for IPADDRESS in $IPADDRESSESV4;
              do
                      printf "IP: $IPADDRESS" > /etc/issue
              done;
      
      echo "" >> /etc/issue
      
  • Make the script executable:
    chmod +x /usr/local/etc/rc.d/update-issue
    
  • Start and enable the script at boot:
    echo 'update_issue_enable="YES"' >> /etc/rc.conf
    service update-issue start
    

Resources

History

#1 Updated by Daniel Curtis almost 3 years ago

  • Estimated time set to 0.50
  • % Done changed from 0 to 100
  • Status changed from New to Resolved
  • Description updated (diff)

#2 Updated by Daniel Curtis over 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF