红旗自行车 發表於 2017-1-22 17:05:23

Centos7系统怎么修改IP地址?

<p>本文主要针对Centos7修改IP地址的方法进行阐述</p>
<p><strong>一、进入网络配置文件目录</strong></p>
<p>首先,确保在root用户下进行操作。进入网络配置文件network-scripts目录下。</p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/201701/20170122165742178.png" /> </p>
<p>二、<strong>找到我们需要修改的配置文件</strong></p>
<p>使用ls命令,列出该目录下的文件。其中&ldquo;<strong><font color="#ff0000">ifcfg-ens33</font></strong>&rdquo;(红框)的文件,为我们需要修改的网络配置文件。</p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/201701/20170122165742179.png" /> </p>
<p><strong>三、修改配置文件</strong></p>
<p>使用<strong><font color="#ff0000">vim命令</font></strong>(vi命令也可以),对文件进行配置,我们需要修改<strong>BOOTPROTO=&quot;static</strong>&quot;也就是将dhcp改为static,修改<strong>ONBOOT=&quot;yes&quot;</strong> 意思是将网卡设置 为开机启用,同时在文字下方添加</p>
<p><strong>IPADDR=192.168.0.230</strong> #静态IP&nbsp;&nbsp;</p>
<p><strong>GATEWAY=192.168.0.1 #</strong>默认网关&nbsp;&nbsp;</p>
<p><strong>NETMASK=255.255.255.0&nbsp;#</strong>子网掩码&nbsp;&nbsp;</p>
<p><strong>DNS1=192.168.0.1 #</strong>DNS&nbsp;配置 &nbsp;</p>
<p><strong>DNS2=8.8.8.8</strong> &nbsp; &nbsp; &nbsp; &nbsp;#谷歌地址</p>
<p>红框为修改内容,紫框为需要添加的内容。</p>
<p><strong><font color="#ff0000">ESC+WQ</font></strong>,保存退出!</p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/201701/20170122165742180.png" /> </p>
<p><strong>四、重启网络服务</strong></p>
<p>使用<strong><font color="#ff0000">service&nbsp;network&nbsp;restart命令</font></strong>,重启网络服务。(红框为重启网络服务命令,蓝框为重启网络服务状态)</p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/201701/20170122165743181.png" /> </p>
<p><strong>五、查看我们改动后的效果</strong></p>
<p>因为现在是Centos7所以我们使用新的命令,我们输入<strong>ip addr进行查看</strong>。(红框为查看命令,蓝框为网卡状态)</p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/201701/20170122165743182.png" /> </p>
<p><strong>相关推荐:</strong> </p>
<p><a target="_blank" href="https://www.jb51.net/os/RedHat/520214.html">centos7没有ifconfig命令该怎么办?</a> </p>
頁: [1]
查看完整版本: Centos7系统怎么修改IP地址?