Red Hat Enterprise Linux 7(RHEL7)配置静态IP地址
1.验证网络管理器状态,Active: active (running)表示正在运行,一般RHEL7都默认安装了。
[root@localhost ~]# systemctl status NetworkManager.service
NetworkManager.service – Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled)
Active: active (running) since 一 2015-06-22 18:50:22 CST; 26min ago
Main PID: 895 (NetworkManager)
CGroup: /system.slice/NetworkManager.service
└─895 /usr/sbin/NetworkManager –no-daemon
2.查看网络设备以及状态
[root@localhost ~]# nmcli dev
设备 类型 状态 CONNECTION
enp0s3 ethernet 连接的 enp0s3
lo loopback 未管理 —
我只关心类型为ethernet(以太网)的设备,如果该设备状态不是连接的,则启用它
[root@localhost ~]# nmcli con up id enp0s3
3.查看目录/etc/sysconfig/network-scripts下是否有该设备的配置文件,ifcfg-enp0s3,如果没有就新建一个
[root@localhost ~]# ls /etc/sysconfig/network-scripts
ifcfg-enp0s3 ifdown-ppp ifup-eth ifup-sit
ifcfg-lo ifdown-routes ifup-ippp ifup-Team
ifdown ifdown-sit ifup-ipv6 ifup-TeamPort
ifdown-bnep ifdown-Team ifup-isdn ifup-tunnel
ifdown-eth ifdown-TeamPort ifup-plip ifup-wireless
ifdown-ippp ifdown-tunnel ifup-plusb init.ipv6-global
ifdown-ipv6 ifup ifup-post network-functions
ifdown-isdn ifup-aliases ifup-ppp network-functions-ipv6
ifdown-post ifup-bnep ifup-routes
4.编辑这个配置文件
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
重点是这几个配置
TYPE=Ethernet
BOOTPROTO=static
NAME=enp0s3
ONBOOT=yes
IPADDR=地址
NETMASK=掩码
GATEWAY=网关
DNS1=你的DNS
5.重启网络服务
[root@localhost ~]# systemctl restart network
6.设置ok了,ping www.linuxidc.com试试吧。
更多RedHat相关信息见RedHat 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=10
本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-11/148769.htm