Centos 7.1安裝後修改主機名及網路配置

hunterjoy發表於2015-05-24
Centos 7.1下修改主機名:

[root@localhost ~]# hostnamectl status
   Static hostname: localhost.localdomain
         Icon name: computer
           Chassis: n/a
        Machine ID: caa35e54020e4930a35b28c8e501b51a
           Boot ID: 95321dfa104f423d9d1fc7dbade66dbb
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-229.el7.x86_64
      Architecture: x86_64
[root@localhost ~]# hostnamectl set-hostname linfytest3
[root@localhost ~]# hostnamectl status
   Static hostname: linfytest3
         Icon name: computer
           Chassis: n/a
        Machine ID: caa35e54020e4930a35b28c8e501b51a
           Boot ID: 95321dfa104f423d9d1fc7dbade66dbb
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-229.el7.x86_64
      Architecture: x86_64

Centos 7.1網路配置
新安裝的Centos7.1如何配通網路,如下:
在Centos7.1中檢視網路配置不建議使用ifconfig,而是ip addr
1、在/etc/hosts中配置
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.0.2.151 linfytest3 linfytest3.example.com
2、在/etc/sysconfig/network-scripts中配置
vi ifcfg-eno16777736    --注意,已經不是 ifcfg-eth0
增加配置項:
IPADDR=192.0.2.151
NETMASK=255.255.255.0
NM_CONTROLLED=no
“NM_CONTROLLED=no”表示該介面將透過該配置檔案進行設定,而不是透過網路管理器進行管理。“ONBOOT=yes”告訴我們,系統將在啟動時開啟該介面。
修改配置項:
BOOTPROTO=no  (原來是BOOTPROTO=dhcp
ONBOOT=no     (原來是ONBOOT=yes
3、重啟服務
systemctl restart network.service
4、檢視網路配置
[root@linfytest3 network-scripts]# ip addr
1: lo: mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno16777736: mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:7d:3b:1c brd ff:ff:ff:ff:ff:ff
    inet 192.0.2.151/24 brd 192.0.2.255 scope global eno16777736
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe7d:3b1c/64 scope link 
       valid_lft forever preferred_lft forever
3: virbr0: mtu 1500 qdisc noqueue state DOWN 
    link/ether 52:54:00:98:74:f4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500
    link/ether 52:54:00:98:74:f4 brd ff:ff:ff:ff:ff:ff

5、如果是虛機VMWARE,需要將
VMnet1的地址配置成一個網段192.0.2.X


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/543979/viewspace-1669106/,如需轉載,請註明出處,否則將追究法律責任。

相關文章