虚拟机启动后,显示系统和内核版本。
通过修改
/etc/issue
, 显示IP地址,方法如下:
# cp /etc/issue /etc/issue_standard
创建脚本 /etc/init.d/show_ip.sh
#!/bin/bash
cp /etc/issue_standard /etc/issue
/usr/sbin/ip addr | grep "inet" |grep -v "inet6" | grep -v "127.0.0.1" | awk '{print $2}' >> /etc/issue
echo "" >> /etc/issue
配置脚本开机自启动。
echo "/etc/init.d/show_ip.sh" >> /etc/rc.local
chmod a+x /etc/rc.local
重启服务器,在登录前就可以看到IP了。
参考:
https://type.so/linux/centos-issue-ip.html
https://blog.csdn.net/wang123459/article/details/79063703