linux配置主機名詳細介紹
1. 配置Linux hostname
下面配置兩臺centos7 虛擬機,主機名分別配置為client和server,它們主機IP 地址分別為192.168.30.8和192.168.30.9。
配置client主機
[root@client ~]# vi /etc/sysconfig/network
添加如下內(nèi)容,保存:
# Created by anaconda NETWORKING=yes hostname=client
重啟網(wǎng)絡:
[root@client ~]# systemctl restart network [root@client ~]# hostname client [root@client ~]#
如果不生效可以使用如下命令:
[root@client ~]# hostnamectl set-hostname client
配置server主機
[root@server ~]# hostnamectl set-hostname server
重啟網(wǎng)絡:
[root@server ~]# systemctl restart network [root@server ~]# hostname server [root@server ~]# uname -n server
2. 配置hostname與IP映射
配置client和server的hosts文件
vi /etc/hosts
添加如下內(nèi)容:
192.168.30.8 client 192.168.30.9 server
3. 測試
通過ping hostname來測試是否配置成功:
client ping server:
[root@client ~]# ping server -c 3 PING server (192.168.30.9) 56(84) bytes of data. 64 bytes from server (192.168.30.9): icmp_seq=1 ttl=64 time=0.616 ms 64 bytes from server (192.168.30.9): icmp_seq=2 ttl=64 time=0.384 ms 64 bytes from server (192.168.30.9): icmp_seq=3 ttl=64 time=0.566 ms --- server ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2001ms rtt min/avg/max/mdev = 0.384/0.522/0.616/0.099 ms [root@client ~]#
server ping client:
[root@Server ~]# ping client -c 3 PING client (192.168.30.8) 56(84) bytes of data. 64 bytes from client (192.168.30.8): icmp_seq=1 ttl=64 time=0.502 ms 64 bytes from client (192.168.30.8): icmp_seq=2 ttl=64 time=0.678 ms 64 bytes from client (192.168.30.8): icmp_seq=3 ttl=64 time=0.323 ms --- client ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 0.323/0.501/0.678/0.144 ms [root@Server ~]#
配置hostname與IP映射后,可以直接ping主機名而不用ping IP地址了。
4. 配置windows hosts
配置windows hosts,以便在windows下面能通過主機名進行訪問。
編輯 C:\Windows\System32\drivers\etc\hosts文件,添加如下內(nèi)容:
192.168.30.8 client 192.168.30.9 server
保存
5. windows測試
C:\Users\10287>ping client -n 3 正在 Ping client [192.168.30.8] 具有 32 字節(jié)的數(shù)據(jù): 來自 192.168.30.8 的回復: 字節(jié)=32 時間<1ms TTL=64 來自 192.168.30.8 的回復: 字節(jié)=32 時間<1ms TTL=64 來自 192.168.30.8 的回復: 字節(jié)=32 時間<1ms TTL=64 192.168.30.8 的 Ping 統(tǒng)計信息: 數(shù)據(jù)包: 已發(fā)送 = 3,已接收 = 3,丟失 = 0 (0% 丟失), 往返行程的估計時間(以毫秒為單位): 最短 = 0ms,最長 = 0ms,平均 = 0ms
到此這篇關于linux配置主機名詳細介紹的文章就介紹到這了,更多相關linux配置主機名內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
VPS主機CentOS系統(tǒng)安裝LNMP環(huán)境圖文教程分享
今天先來在CentOS中安裝LNMP系統(tǒng),最低的系統(tǒng)要求為128M內(nèi)存,我相信大家的VPS最低也應該有256M內(nèi)存,我測試的機器為512M內(nèi)存,HE機房線路機器2012-09-09CentOS6.5安裝glibc-2.14后locale出現(xiàn)No?such?file?or?directory解
大家好,本篇文章主要講了CentOS6.5安裝glibc-2.14后locale出現(xiàn)No?such?file?or?directory解決辦法,感興趣的同學趕快來看看吧,希望對你有幫助2021-11-11ubuntu中python調(diào)用C/C++方法之動態(tài)鏈接庫詳解
這篇文章主要給大家介紹了關于如何在ubuntu中python調(diào)用C/C++方法之動態(tài)鏈接庫的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起看看吧2018-11-11linux普通用戶su root切換提示沒有文件或目錄的解決方法
這篇文章主要介紹了linux普通用戶su root切換提示沒有文件或目錄的解決方法,需要的朋友可以參考下2017-07-07