政客 發表於 2019-10-15 11:22:00

CentOS 8 网卡设置

<p><span style="font-size: 18px; background-color: rgba(128, 128, 0, 1)"><strong>本次测试环境是在虚拟机上测试</strong></span></p>
<p>网卡配置文件路径:/etc/sysconfig/network-scripts/ifcfg-ens33</p>
<p># cd /etc/sysconfig/network-scripts/&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #进入网卡配置路径<br># ll&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#列出文件,找到ifcfg-ens33网卡配置文件</p>
<p><img src="https://img2018.cnblogs.com/blog/1785556/201910/1785556-20191015102735720-250812027.png"></p>
<p>&nbsp;</p>
<p># vim ifcfg-ens33&nbsp;</p>
<div class="cnblogs_code">
<pre><em id="__mceDel"><span style="color: rgba(0, 0, 0, 1)">TYPE=Ethernet<br>PROXY_METHOD</span>=<span style="color: rgba(0, 0, 0, 1)">none   
BROWSER_ONLY</span>=<span style="color: rgba(0, 0, 0, 1)">no
BOOTPROTO</span>=<span style="color: rgba(0, 0, 0, 1)">none             #dhcp改为none或者static
DEFROUTE</span>=<span style="color: rgba(0, 0, 0, 1)">yes
NAME</span>=<span style="color: rgba(0, 0, 0, 1)">ens33
DEVICE</span>=<span style="color: rgba(0, 0, 0, 1)">ens33
ONBOOT</span>=<span style="color: rgba(0, 0, 0, 1)">yes                #no 改为 yes
IPADDR</span>=<span style="color: rgba(128, 0, 128, 1)">192.168</span>.<span style="color: rgba(128, 0, 128, 1)">1.130  #添加IP</span><span style="color: rgba(0, 0, 0, 1)">
NETMASK</span>=<span style="color: rgba(128, 0, 128, 1)">255.255</span>.<span style="color: rgba(128, 0, 128, 1)">255.0   #添加子网掩码<br></span><span style="color: rgba(0, 0, 0, 1)">GATEWAY</span>=<span style="color: rgba(128, 0, 128, 1)">192.168</span>.<span style="color: rgba(128, 0, 128, 1)">1.1    #添加网关</span></em></pre>
</div>
<p>&nbsp;</p>
<p># nmcli c reload&nbsp; &nbsp; &nbsp;#重载网卡即可,centos 8重载网卡命令从systemctl改为nmcli来加载网卡了。</p>
<p>&nbsp;</p>
<p>接下来就是ping测试看看,ping www.baidu.com 看看返回值,如果是返回截图下的值,可以绑定一下DNS来解决该问题</p>
<p><img src="https://img2018.cnblogs.com/blog/1785556/201910/1785556-20191015111932347-2125052077.png"></p>
<p># vi /etc/resolv.conf</p>
<div class="cnblogs_code">
<pre>nameserver <span style="color: rgba(128, 0, 128, 1)">114.114</span>.<span style="color: rgba(128, 0, 128, 1)">114.114</span><span style="color: rgba(0, 0, 0, 1)">
nameserver </span><span style="color: rgba(128, 0, 128, 1)">8.8</span>.<span style="color: rgba(128, 0, 128, 1)">8.8</span></pre>
</div>
<p><img src="https://img2018.cnblogs.com/blog/1785556/201910/1785556-20191015112119651-1579650685.png"></p>
<p>&nbsp;</p><br><br>
来源:https://www.cnblogs.com/xiehualang/p/11676552.html
頁: [1]
查看完整版本: CentOS 8 网卡设置