云游记 發表於 2023-10-28 00:00:00

Linux网络搭建基础实验(1)

<p>
        <strong>一、实验目标</strong></p>
<p>
        利用3台虚拟机,搭建vmnet2和vmnet3两个host-only网络,实现两个网络的互联</p>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/364512c3f8f9f77d17f7fe80cac2ed25.jpg"></p>
<p>
        <strong>二、实验环境</strong></p>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" id="theimg" src="https://zhuji.jb51.net/uploads/img/202305/b4795a3f23025b070a9f78001cc54ab5.jpg"></p>
<p>
        <strong>三、实验步骤</strong></p>
<p>
        <strong>1、添加vmnet2和vmnet3,并取消其dhcp功能</strong></p>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/ef1f63d228d3375563dd4eb2ea4f1d6d.jpg"></p>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/72213ab8725dcd3cf8a0c1da1e901dcc.jpg"></p>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/f1796b5d5e00fb842dd217083a7b403f.jpg"></p>
<p>
        <strong>2、内网虚拟机的设置</strong></p>
<p>
        (1)解决网卡不一致的问题,为其设置静态ip、子网掩码和网关</p>
<div class="jb51code">
        <div>
                <div class="syntaxhighlighterbash" id="highlighter_159059">
                        <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>
                                                </td>
                                                <td class="code">
                                                        <div class="container">
                                                                <div class="line number1 index0 alt2">
                                                                        <code class="bash plain"></code><code class="bash comments"># gedit /etc/sysconfig/network-scripts/ifcfg-eth0 //编辑网卡信息</code>
</div>
                                                        </div>
                                                </td>
                                        </tr></tbody></table>
</div>
        </div>
</div>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/cd2c552cd8d29960601d206003670fdc.jpg"></p>
<p>
        (2)将内网虚拟机加入vmnet2</p>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/60a1e65c17ca82fc8f2ad3c903f7253e.jpg"></p>
<p>
        (3)重启网络服务</p>
<div class="jb51code">
        <div>
                <div class="syntaxhighlighterbash" id="highlighter_664981">
                        <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>
                                                </td>
                                                <td class="code">
                                                        <div class="container">
                                                                <div class="line number1 index0 alt2">
                                                                        <code class="bash plain"></code><code class="bash comments"># service network restart</code>
</div>
                                                        </div>
                                                </td>
                                        </tr></tbody></table>
</div>
        </div>
</div>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/059a0d8dc5f380bd7bd6650aa91dc57c.jpg"></p>
<p>
        (4)查看是否获取到设置的ip地址</p>
<div class="jb51code">
        <div>
                <div class="syntaxhighlighterbash" id="highlighter_742667">
                        <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>
                                                </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>
                                                </td>
                                        </tr></tbody></table>
</div>
        </div>
</div>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/6d109d4b8ca84c3d4bb2799ce1805dad.jpg"></p>
<p>
        <strong>3、外网虚拟机的设置</strong></p>
<p>
        解决网卡不一致的问题,为其设置静态ip、子网掩码和网关,并将其加入vmnet3,操作同内网虚拟机的设置</p>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/f6e7c7ac7c644ae4a02066d5df670953.jpg"></p>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/1e8649fb6054b29c2a235b038261f8db.jpg"></p>
<p>
        <strong>4、网关虚拟机的设置</strong></p>
<p>
        (1)为网关虚拟机添加一块网卡,并设置其两卡所属网络,将eth0加入vmnet2,eth1加入vmnet3</p>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/b60f8bb0471d5572a673f4edbcede8d8.jpg"></p>
<p>
        (2)解决两块网卡不一致的问题,分别为其设置静态ip、子网掩码和网关</p>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/c54c94d8c8773a49c8996b829019e3ee.jpg"></p>
<p>
        (3)开启转发功能</p>
<div class="jb51code">
        <div>
                <div class="syntaxhighlighterbash" id="highlighter_352795">
                        <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"># gedit /etc/sysctl.conf  //打开系统参数配置文件</code>
</div>
                                                                <div class="line number2 index1 alt1">
                                                                        <code class="bash plain"></code><code class="bash comments"># sysctl -p  //使配置文件生效</code>
</div>
                                                                <div class="line number3 index2 alt2">
                                                                        <code class="bash plain"></code><code class="bash comments"># servcie iptables stop  //暂时关闭防火墙</code>
</div>
                                                        </div>
                                                </td>
                                        </tr></tbody></table>
</div>
        </div>
</div>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/4da462ae923fa41919b329ea53e76407.jpg"></p>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/b77b5ea06be916745cd97b4f8e5cd499.jpg"></p>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/12819ab96c178877643cbc8abff27dd7.jpg"></p>
<p>
        <strong>四、结果测试</strong></p>
<p>
        在内网虚拟机上ping外网虚拟机,发现已经可以ping通!</p>
<div class="jb51code">
        <div>
                <div class="syntaxhighlighterbash" id="highlighter_853477">
                        <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>
                                                </td>
                                                <td class="code">
                                                        <div class="container">
                                                                <div class="line number1 index0 alt2">
                                                                        <code class="bash plain"></code><code class="bash comments"># ping 202.3.4.10</code>
</div>
                                                        </div>
                                                </td>
                                        </tr></tbody></table>
</div>
        </div>
</div>
<p>
        <img title="Linux网络搭建基础实验(1)" alt="Linux网络搭建基础实验(1)" src="https://zhuji.jb51.net/uploads/img/202305/96bdcc44874200b268287133e5c7021e.jpg"></p>
<p>
        以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>
頁: [1]
查看完整版本: Linux网络搭建基础实验(1)