ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Centos 7.1安装后修改主机名及网络配置

Centos 7.1安装后修改主机名及网络配置

原创 Linux操作系统 作者:hunterjoy 时间:2015-05-24 08:43:55 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/543979/viewspace-1669106/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-12-31

  • 博文量
    168
  • 访问量
    389689