Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show IP in login prompt (?) #63322

Open
davidak opened this issue Jun 17, 2019 · 9 comments
Open

Show IP in login prompt (?) #63322

davidak opened this issue Jun 17, 2019 · 9 comments

Comments

@davidak
Copy link
Member

davidak commented Jun 17, 2019

Issue description

I have a NixOS installation without graphical user interface and use DHCP to get an IP.

I have power, ethernet and a display connected to the device.

To connect via ssh, i have to connect a keyboard and type the password to login and get the IP.

It would be helpful to see the primary IP in login prompt!

It's probably not that easy to get the primary IP. On traditional systems the NIC is called eth0, but with systemd, it's called differently on every system. In my case, i use a bridge called br0.

For my nixos-containers, i use ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}' to get the IP.

The login help text seem to be defined here: https://github.com/NixOS/nixpkgs/blob/release-19.03/nixos/modules/services/ttys/agetty.nix

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.19.46, NixOS, 19.03.172758.36516712916 (Koi)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.2.2
  • channels(root): "nixos-19.03.172883.1601f559e89"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
@cleverca22
Copy link
Contributor

my typical solution to this is to services.avahi.enable = true; and then run avahi-browse -at on another machine to list all avahi machines on the LAN

@gloaming
Copy link
Contributor

gloaming commented Jun 29, 2019

This is already supported by agetty(8):

ISSUE FILES

       The default issue file is /etc/issue. If the file exists then agetty
       also checks for /etc/issue.d directory. The directory is optional
       extension to the default issue file and content of the directory is
       printed after /etc/issue content. If the /etc/issue does not exist
       than the directory is ignored. All files with .issue extension from
       the directory are printed in version-sort order. The directory allow
       to maintain 3rd-party messages independently on the primary system
       /etc/issue file.

       The default path maybe overridden by --issue-file option. In this
       case specified path has to be file or directory and the default
       /etc/issue as well as /etc/issue.d are ignored.

       The issue files may contain certain escape codes to display the
       system name, date, time etcetera.  All escape codes consist of a
       backslash (\) immediately followed by one of the characters listed
       below.

       4 or 4{interface}
              Insert the IPv4 address of the specified network interface
              (for example: \4{eth0}).  If the interface argument is not
              specified, then select the first fully configured (UP, non-
              LOCALBACK, RUNNING) interface.  If not any configured
              interface is found, fall back to the IP address of the
              machine's hostname.

But there's no guarantee that DHCP has assigned an address when it runs, and the IP might change later, so you'll want to do

  environment.etc."issue.d/ip.issue".text = "\\4\n";
  networking.dhcpcd.runHook = "${pkgs.utillinux}/bin/agetty --reload";

Which works on my machine.
But this seems like an odd thing to do. Why don't you just configure a static IP?

@mmahut
Copy link
Member

mmahut commented Jun 29, 2019

Are any other linux distributions that are doing this? I know some of the *BSD did, but not sure about linux.

@stale
Copy link

stale bot commented Jun 2, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 2, 2020
@davidak
Copy link
Member Author

davidak commented Oct 29, 2020

#63322 (comment) works. The login took longer to appear.

Should we make this a NixOS option (enableIP...) or just document it (where? wiki?)?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 29, 2020
@stale
Copy link

stale bot commented Jun 6, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 6, 2021
@573
Copy link
Contributor

573 commented Apr 19, 2022

Still interested in this.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 19, 2022
@davidak
Copy link
Member Author

davidak commented Apr 22, 2022

@573 what solution would you like to have?

@573
Copy link
Contributor

573 commented Apr 22, 2022

I guess I would prefer to have it as a NixOS option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants