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