RHCSA考题一 :配置hostname和网络
在mars.lab.example.com上,将mars配置为具有以下网络配置:
- 主机名: mars.lab.example.com image
- IP地址: 172.25.250.10
- 子网掩码:255.255.255.0
- 网关: 172.25.250.254
- DNS: 72.25.250.254
提示
hostnamectl nmcli
Answer:
-
设置hostname
- 方法一:
hostnamectl set-hostname mars.lab.example.com
- 方法二:编写 hostname配置文件设置,
vim /etc/hostname
- 方法一:
-
设置网络
- 方法一:
nmcli connection show #查看网卡名,比如这里是 Wired connection1 nmcli connection modify "Wired connection1" \ ipv4.method manual \ ipv4.addresses 172.25.250.10/24 \ ipv4.gateway 172.25.250.254 \ ipv4.dns 172.25.250.254 \ connect.autoconnect yes nmcli connection up "Wired connection1 "
- 方法二:
编写网卡配置文件设置
vim /etc/sysconfig/network-scripts/ifcfg-Wired_connection1
ipaddr 172.25.250.20 改成172.25.250.10
nmcli connection reload nmcli connection up "Wired connection1"
- 方法一:
验证:
- hostname
- IP
ip a
或者
ssh root@mars