How to configure a static IP address on CentOS 7(CentOS7静态IP地址设置)
Question: On CentOS 7, I want to switch from DHCP to static IP address configuration with one of my network interfaces. What is a proper way to assign a static IP address to a network interface permanently on CentOS or RHEL 7?
If you want to set up a static IP address on a network interface in CentOS 7, there are several different ways to do it, varying depending on whether or not you want to use Network Manager for that.
Network Manager is a dynamic network control and configuration system that attempts to keep network devices and connections up and active when they are available). CentOS/RHEL 7 comes with Network Manager service installed and enabled by default.
To verify the status of Network Manager service:
To check which network interface is managed by Network Manager, run:

<img src="https://farm4.staticflickr.com/3861/15295802711_a102a3574d_z.jpg">
If the output of nmcli shows "connected" for a particular interface (e.g., enp0s3 in the example), it means that the interface is managed by Network Manager. You can easily disable Network Manager for a particular interface, so that you can configure it on your own for a static IP address.
Here are two different ways to assign a static IP address to a network interface on CentOS 7. We will be configuring a network interface named enp0s3.
Configure a Static IP Address without Network Manager
Go to the /etc/sysconfig/network-scripts directory, and locate its configuration file (ifcfg-enp0s3). Create it if not found.

<img src="https://farm4.staticflickr.com/3911/15112399977_d3df8e15f5_z.jpg">
Open the configuration file and edit the following variables:

<img src="https://farm4.staticflickr.com/3880/15112184199_f4cbf269a6.jpg">
In the above, "NM_CONTROLLED=no" indicates that this interface will be set up using this configuration file, instead of being managed by Network Manager service. "ONBOOT=yes" tells the system to bring up the interface during boot.
Save changes and restart the network service using the following command:
Now verify that the interface has been properly configured:

<img src="https://farm6.staticflickr.com/5593/15112397947_ac69a33fb4_z.jpg">
Configure a Static IP Address with Network Manager
If you want to use Network Manager to manage the interface, you can use nmtui (Network Manager Text User Interface) which provides a way to configure Network Manager in a terminal environment.
Before using nmtui, first set "NM_CONTROLLED=yes" in /etc/sysconfig/network-scripts/ifcfg-enp0s3.
Now let's install nmtui as follows.
Then go ahead and edit the Network Manager configuration of enp0s3 interface:
The following screen will allow us to manually enter the same information that is contained in /etc/sysconfig/network-scripts/ifcfg-enp0s3.
Use the arrow keys to navigate this screen, press Enter to select from a list of values (or fill in the desired values), and finally click OK at the bottom right:

<img src="https://farm4.staticflickr.com/3878/15295804521_4165c97828_z.jpg">
Finally, restart the network service.
and you're ready to go.
How to configure a static IP address on CentOS 7(CentOS7静态IP地址设置)的更多相关文章
- CentOS 6.5静态IP的设置(NAT和桥接都适用)
CentOS 6.5静态IP的设置(NAT和桥接都适用) 为了方便,用Xshell来.并将IP设置为静态的.因为,在CentOS里,若不对其IP进行静态设置的话,则每次开机,其IP都是动态变化的,这样 ...
- CentOS 7 配置静态IP后不生效 & Job for network.service failed
参考:http://tieba.baidu.com/p/3233996339#57290767555l 在CentOS中配置静态IP后不生效. 解决办法:将/etc/sysconfig/network ...
- 为CentOS 7配置静态IP地址及遇到的问题解决策略
为CentOS 7配置静态IP地址及遇到的问题解决策略 1. 为CentOS 7配置静态IP地址的两种方法 (原文地址:http://www.linuxidc.com/Linux/2014-10/10 ...
- centos系统设置局域网静态IP
---恢复内容开始--- centos系统设置局域网静态IP 很多时候,我们并不希望漏油器重启之后,自己的服务器动态的获取IP,这样很不利,因为你可能装了mysql,redis,等软件,然后需要远程去 ...
- centos 7配置静态IP,并配置DNS
注意:四 个文件 cat /etc/sysconfig/network-scripts/ifcfg-eth0 cat /etc/sysconfig/network cat /etc/resolv.co ...
- 33. CentOS7 静态ip设置
1.网络连接选择NAT模式: 2.关闭vmware的dhcp:选择编辑-->虚拟网络编辑器,选择VMnet8,去掉使用本地DHCP服务将ip地址分配给虚拟机(D). 3. 点击NAT设置(S)查 ...
- 如何为CentOS 7配置静态IP地址
问题:在CentOS 7上,我想要将我其中一个网络接口从DHCP改为静态IP地址配置,如何才能永久为CentOS或RHEL 7上的网络接口分配静态IP地址? 如果你想要为CentOS 7中的某个网络接 ...
- CentOS 7配置静态IP地址的两种方法 来自:互联网
CentOS 7配置静态IP地址的两种方法 来自:互联网 时间:2021-01-12 阅读:4 如果你想要为CentOS 7中的某个网络接口设置静态IP地址,有几种不同的方法,这取决于你是否想要使用网 ...
- Mac VMware Fusion Centos7 静态ip配置
一直没用mac装过虚拟机,最近因为一些原因不得不装一个,但是被这个静态ip配置把头都搞痛了(这里吐槽一下百度,我前几页都看了几遍,搜索关键字就是我现在的标题,结果都是一些抄抄抄并且不管用的攻略,最后使 ...
随机推荐
- 【Linux】学习说明
概述Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和UNIX的多用户.多任务.支持多线程和多CPU的操作系统.多用户是指操作系统可以创建多个用户,用户可以并行的使用操作系 ...
- wordpress stratus模板使用 产品显示问题
产品不显示,只显示展示产品代码. 1.研究原站demo,思考产品展示调用自woocommerce. 2.查看woocommerce文档,更新展示代码. 3.修改后产品出现,但是多余的关联推荐也展示出来 ...
- 湖人VS爵士!!科比4月14日最后一战,本赛季最高得分!狂得60分!!完美大逆转!!!
莫愁前路无知己,天下谁人不识君.科比,愿你如迈克尔·乔丹,仍然活跃在篮球界.退役不是结束,而是另一段人生的开始. 北京时间2016年4月14日,湖人101-96击败爵士,科比-布莱恩特告别战,20年职 ...
- crontab 提示 command not found 解决方案
今天遇见一个问题,crontab的定时任务会报错:java command not found,但是手动执行脚本一直能成功. 猜想是环境变量的问题. 在crontab里添加个打印环境变量的任务: * ...
- Google Protocol Buffer 的使用
简介 Google Protocol Buffer( 简称 Protobuf) 是 Google 公司内部的混合语言数据标准,目前已经正在使用的有超过 48,162 种报文格式定义和超过 12,183 ...
- KBMMW 4.93.10 发布
例行更新,主要是bugfix. 4.93.10 June 4 2016 Important notes (changes that may break existing code) ========= ...
- 论Segmentation fault
刚开始学c的时候,最头疼的事情是编译总是通不过,郁闷的要死,只要编译通过了,就兴奋的要死.现在,最头疼的事情是什么呢,编译没问题,但是程序跑的时候会出现Segmentation fault! 这个东西 ...
- 操作素有的ul的元素
1 $(function() { var all = $(".test"); $(".test").each(function() { var y = $(th ...
- python之路-Day7
编程范式 编程是 程序 员 用特定的语法+数据结构+算法组成的代码来告诉计算机如何执行任务的过程 , 一个程序是程序员为了得到一个任务结果而编写的一组指令的集合,正所谓条条大路通罗马,实现一个任务的方 ...
- iOS 利用for循环创建九宫格
// 利用for循环创建九宫格 - (void)createScratchableLatex{ // 总列数 ; // 每一格的尺寸 CGFloat cellW = (self.frame.size. ...