以下文章摘自http://blog.xuite.net/tolarku/blog/359546118-CentOS+7+%E4%BF%AE%E6%94%B9%E4%B8%BB%E6%A9%9F%E5%90%8D%E7%A8%B1+-+hostnamectl+
在之前的 CentOS 或其他的 Unix 主機,想要修改主機名稱可以使用「hostname」指令。但到 CentOS 7 之後,雖然 hostname 指令還在卻沒作用了,去修改 /etc/sysconfig/network 也沒作用 ...... 這是因為他改用了「hostnamectl 」指令了。
hostnamectl - Control the system hostname
# 查看目前的主機名稱 #
hostnamectl
$ hostnamectl
Static hostname: localhost.localdomain
Transient hostname: web2
Icon name: computer
Chassis: n/a
Machine ID: 927683d8736xx3345622b982d75
Boot ID: 8226be1192e74w532525c235325f38
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-229.20.1.el7.x86_64
Architecture: x86_64
# 設定主機名稱 #
hostnamectl set-hostname [NAME]
$ hostnamectl set-hostname www
==== AUTHENTICATING FOR org.freedesktop.hostname1.set-static-hostname ===
Authentication is required to set the statically configured local host name, as well as the pretty host name.
Authenticating as: root
## 這個功能是 CentOS 7 提供的新作法,假設一般使用者要執行需要 root 權限的指令,他會跳出要你輸入 root 的密碼來做驗證,驗證過當然就執行囉!....這跟以往直接跟你說需要 root 權限不一樣。
$ sudo hostnamectl set-hostname www
[user@www ~]$
有這個指令之後,就不用再去修改 network 設定了,直接一行指令搞定,重開機也不會改變了。
>> 這個動作會寫入到 /proc/sys/kernel/hostname 設定檔裡
----------------
另外針對主機名稱多了「icon-name」、「chassis」
set-icon-name [NAME]
Set the system icon name. The icon name is used by some graphical applications to visualize this host. The icon
name should follow the Icon Naming Specification[1]. Pass an empty string to this operation to reset the icon name
to the default value, which is determined from chassis type (see below) and possibly other parameters.
set-chassis [TYPE]
Set the chassis type. The chassis type is used by some graphical applications to visualize the host or alter user
interaction. Currently, the following chassis types are defined: "desktop", "laptop", "server", "tablet",
"handset", as well as the special chassis types "vm" and "container" for virtualized systems that lack an
immediate physical chassis. Pass an empty string to this operation to reset the chassis type to the default value
which is determined from the firmware and possibly other parameters.
~End
2016年8月4日 星期四
2011年4月11日 星期一
Private IP 說明
Private IP俗稱虛擬IP,內部網路連線使用。
根據 RFC 1918 - Address Allocation for Private Internets 說明,有以下三段IP保留給內部網路使用:
以192.168開頭的IP為例:
IP設定
192.168.0.X ~ 192.168.255.X,X=1~254
網路遮罩(netmask)設定
255.255.255.0
廣播位址(broadcast)設定
192.168.Y.255,Y=0~255
都算是標準的Private IP使用方式。
有一個地方需要注意的是,若廣播位址(broadcast)隨意設定,可能會影響netmask與可以用的IP數量,所以一般都直接拿最大的255設定即可。
<<題外話>>
若不連上Internet,其實IP怎麼設定都是OK的,遵循RFC1918的規範設定,主要是為了便於辨認IP是Private IP或是Public IP,以及避免連上Internet時與其他真實IP重複,造成網路連線異常。
以上資料摘自於http://forum.liferec.com/viewtopic.php?p=488
根據 RFC 1918 - Address Allocation for Private Internets 說明,有以下三段IP保留給內部網路使用:
| 代碼: |
| 10.0.0.0 - 10.255.255.255 (10/8 prefix) 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) |
以192.168開頭的IP為例:
IP設定
192.168.0.X ~ 192.168.255.X,X=1~254
網路遮罩(netmask)設定
255.255.255.0
廣播位址(broadcast)設定
192.168.Y.255,Y=0~255
都算是標準的Private IP使用方式。
有一個地方需要注意的是,若廣播位址(broadcast)隨意設定,可能會影響netmask與可以用的IP數量,所以一般都直接拿最大的255設定即可。
<<題外話>>
若不連上Internet,其實IP怎麼設定都是OK的,遵循RFC1918的規範設定,主要是為了便於辨認IP是Private IP或是Public IP,以及避免連上Internet時與其他真實IP重複,造成網路連線異常。
以上資料摘自於http://forum.liferec.com/viewtopic.php?p=488
訂閱:
文章 (Atom)