您的位置:首页 > 理论基础 > 计算机网络

【RHCSA】配置网络和主机名

2021-04-17 23:37 1136 查看


文章目录

[/ul]


前言

配置网络和主机名是RHCSA考试的第一题,2020年8月RHCE,RHCA考试都是用的8的系统。
破解root密码是必会的,因为这个第一题也得需要你破解密码后才能继续做题。在RHCE的考试中,网络必须要对,如果网络不对,基本上是0分。

问题

虚拟机的网络配置要求如下:
主机名: zmgaosh01
ip地址: 192.168.1.66
子网掩码: 255.255.255.0
网关: 192.168.1.1

配置网络

方法一: 修改现有的配置文件

[root@rhce ~]# nmcli connection modify "ens160" ipv4.addresses 192.168.1.66/24 ipv4.gateway 192.168.1.1 ipv4.dns 192.168.1.1[root@rhce ~]# nmcli c up "ens160"连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/7)[root@rhce ~]# [root@rhce ~]# ping 192.168.1.66PING 192.168.1.66 (192.168.1.66) 56(84) bytes of data.
64 bytes from 192.168.1.66: icmp_seq=1 ttl=64 time=0.042 ms

方法二: 添加一个新的配置文件

[root@rhce ~]# nmcli  connection add con-name ens160  ifname ens160  type ethernet ipv4.addresses 192.168.1.68/24 ipv4.gateway 192.168.1.1 ipv4.dns 192.168.1.1

修改hostname

[root@rhce ~]# hostnamerhce[root@rhce ~]# hostnamectl set-hostname zmgash-rhce   [root@rhce ~]# hostnamectl 
   Static hostname: zmgash-rhce
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 03d1aac5d7bf41d3af83d652ea3d0aae
           Boot ID: c2aee93d4af54a0b9e54285a4373907b
    Virtualization: vmware
  Operating System: Red Hat Enterprise Linux 8.0 (Ootpa)   CPE OS Name: cpe:/o:redhat:enterprise_linux:8.0:GA
            Kernel: Linux 4.18.0-80.el8.x86_64
      Architecture: x86-64[root@rhce ~]# hostnamezmgash-rhce[root@rhce ~]#

nmcli的用法

  • nmcli connection show ## 查看当前网络连接
  • nmcli c up ens160 ### 启动ens160
  • nmcli connection delete static 删除网络设备
  • [root@rhce ~]# nmcli connection reload 重启网络
  • nmcli d 查看网卡列表
[root@rhce ~]# nmcli connection show   ## 查看当前网络设备NAME    UUID                                  TYPE      DEVICE 
ens160  4fd526cf-b069-46e9-9e08-5b5b277c2abb  ethernet  ens160 
virbr0  08dc5365-ba51-4f28-8346-0b29d779af64  bridge    virbr0 
ens160  292886e3-4c81-44f4-b7f5-151896aede85  ethernet  --     
static  54fe25cf-8033-4f0f-8c85-b08d69f82f10  ethernet  --     
static  0d5a86c6-1e11-4fb0-a94f-5728c91eba6d  ethernet  --     
static  8e073a3f-47c2-422c-a144-594cec513ca1  ethernet  --     
static  c25bbd5b-3456-44ca-b348-ba90c743c04b  ethernet  --     
[root@rhce ~]# nmcli c up ens160   ### 启动ens160连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/8)[root@rhce ~]# nmcli connection delete static   ## 删除static成功删除连接 "static" (54fe25cf-8033-4f0f-8c85-b08d69f82f10)。
成功删除连接 "static" (0d5a86c6-1e11-4fb0-a94f-5728c91eba6d)。
成功删除连接 "static" (8e073a3f-47c2-422c-a144-594cec513ca1)。
成功删除连接 "static" (c25bbd5b-3456-44ca-b348-ba90c743c04b)。[root@rhce ~]#
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: