快抢手 發表於 2023-8-14 00:00:00

CentOS虚拟机克隆后无法上网(网卡信息不一致)问题的解决方法

<p>
        <strong>一、问题描述</strong></p>
<p>
        虚拟机克隆后,由于网卡信息不一致的问题,导致不能上网或者执行“sercice network restart”命令失败</p>
<div class="jb51code">
        <div>
                <div class="syntaxhighlighterbash" id="highlighter_185914">
                        <div class="toolbar">
                                <span>?</span>
</div>
                        <table border="0" cellpadding="0" cellspacing="0"><tbody><tr>
<td class="gutter">
                                                        <div class="line number1 index0 alt2">
                                                                1</div>
                                                        <div class="line number2 index1 alt1">
                                                                2</div>
                                                        <div class="line number3 index2 alt2">
                                                                3</div>
                                                </td>
                                                <td class="code">
                                                        <div class="container">
                                                                <div class="line number1 index0 alt2">
                                                                        <code class="bash plain"></code><code class="bash comments"># ifconfig  //查看当前网卡信息</code>
</div>
                                                                <div class="line number2 index1 alt1">
                                                                        <code class="bash plain"></code><code class="bash comments"># cd /etc/sysconfig/network-scripts  //进入网卡配置文件目录</code>
</div>
                                                                <div class="line number3 index2 alt2">
                                                                        <code class="bash plain"></code><code class="bash comments"># ls  //查看网卡配置文件中的网卡信息</code>
</div>
                                                        </div>
                                                </td>
                                        </tr></tbody></table>
</div>
        </div>
</div>
<p>
        <img style="max-width:100%!important;height:auto!important;"title="CentOS虚拟机克隆后无法上网(网卡信息不一致)问题的解决方法" alt="CentOS虚拟机克隆后无法上网(网卡信息不一致)问题的解决方法" src="https://zhuji.jb51.net/uploads/img/202305/b625176e15069b7c6e92af3ab858ef03.jpg"></p>
<p>
        <strong>二、原因分析</strong></p>
<p>
        由于克隆后的系统,系统只是修改了虚拟机的名字和mac等,并在/etc/udev/rules.d/70-persistent-net.rules文件中增加了一行名为eth1的设备名</p>
<p>
        <img style="max-width:100%!important;height:auto!important;"title="CentOS虚拟机克隆后无法上网(网卡信息不一致)问题的解决方法" alt="CentOS虚拟机克隆后无法上网(网卡信息不一致)问题的解决方法" src="https://zhuji.jb51.net/uploads/img/202305/853f122459ccee9e772450da7d39f200.jpg"></p>
<p>
        <strong>三、解决方法</strong></p>
<p>
        1、修改文件/etc/udev/rules.d/70-persistent-net.rules和/etc/sysconfig/network-scripts/ifcfg-eth0,使得两个文件中的设备名和mac地址相对应</p>
<p>
         </p>
<div class="codetitle">
        <span><u>复制代码</u></span> 代码如下:</div>
<div class="codebody" id="code41839">
        # gedit /etc/udev/rules.d/70-persistent-net.rules /etc/sysconfig/network-scripts/ifcfg-eth0</div>
<p>
         </p>
<p>
        <img style="max-width:100%!important;height:auto!important;"title="CentOS虚拟机克隆后无法上网(网卡信息不一致)问题的解决方法" alt="CentOS虚拟机克隆后无法上网(网卡信息不一致)问题的解决方法" src="https://zhuji.jb51.net/uploads/img/202305/1d38a62a27cb922fd37fe5e47f8bb9eb.jpg"></p>
<p>
        <img style="max-width:100%!important;height:auto!important;"title="CentOS虚拟机克隆后无法上网(网卡信息不一致)问题的解决方法" alt="CentOS虚拟机克隆后无法上网(网卡信息不一致)问题的解决方法" src="https://zhuji.jb51.net/uploads/img/202305/e8aa87700a46ca4e521d7c79b6a69973.jpg"></p>
<p>
        2、修改完之后保存,然后重启虚拟机,再次查看网卡信息,发现已经正常</p>
<p>
        <img style="max-width:100%!important;height:auto!important;"title="CentOS虚拟机克隆后无法上网(网卡信息不一致)问题的解决方法" alt="CentOS虚拟机克隆后无法上网(网卡信息不一致)问题的解决方法" src="https://zhuji.jb51.net/uploads/img/202305/d4f71a46ca3469ec6980cb8dd1ead284.jpg"></p>
<p>
        以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。</p>
頁: [1]
查看完整版本: CentOS虚拟机克隆后无法上网(网卡信息不一致)问题的解决方法