1. 首页 > ITPUX技术网 > 正文

Linux–hostname配置

1.查看
[root@prod ~]# hostname
prod.localdomain
[root@prod ~]# more /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=prod.localdomain

2.修改/etc/hosts 和 /etc/sysconfig/network(–需要重启生效,永久性修改)
[root@prod ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.1.131 testdb.localdomain testdb

[root@prod ~]# vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=testdb.localdomain

3.使其配置生效(–运行后立即生效(新会话生效),但是在系统重启后会丢失所做的修改)
[root@prod ~]# sysctl kernel.hostname=testdb
kernel.hostname = testdb
或者
[root@prod ~]# hostname testdb

本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html

联系我们

在线咨询:点击这里给我发消息

微信号:itpux-com

工作日:9:30-18:30,节假日休息