大网数据广告活动
服务器运维问答

Showing the IP in the banner before login

· 52CE 我爱测

I have a Linux machine and I want it to show the current IP in the banner that shows before the login prompt is displayed. How can I do that? I considered making a startup script that finds the IP in the MOTD, but found that the …

问题原文

原帖链接 · Ram Rachum · CC BY-SA 3.0

I have a Linux machine and I want it to show the current IP in the banner that shows before the login prompt is displayed. How can I do that? I considered making a startup script that finds the IP in the MOTD, but found that the MOTD gets displayed only after the person logged in, and I need the message to show before the person logged in.

If it matters, this is CentOS, I think version 6.

社区高分解答

原帖链接 · davidsheldon · CC BY-SA 4.0

If you want to show the IP address in the /etc/issue, then you may be able to use \4, or \4{eth0} in the issue file. This certainly works in CentOS 7, and Ubuntu 16.04 and later. To show your IPv6 address, then use \6.

For example:

IP: \4

will be replaced by IP: then your IP address.

Other \ escape sequences that are supported are documented in man agetty

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-05-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。