@font-face { font-family: “MS Mincho” }
@font-face { font-family: 宋体 }
@font-face { font-family: 黑体 }
@font-face { font-family: “Cambria Math” }
@font-face { font-family: 等线 }
@font-face { font-family: 楷体 }
@font-face { font-family: “@楷体” }
@font-face { font-family: “@等线” }
@font-face { font-family: “@MS Mincho” }
@font-face { font-family: “@宋体” }
@font-face { font-family: “@黑体” }
p.MsoNormal, li.MsoNormal, div.MsoNormal { mso-style-unhide: no; mso-style-qformat: yes; mso-style-parent: “”; margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: none; font-size: 14pt; mso-bidi-font-size: 11.0pt; font-family: 等线; mso-ascii-font-family: 等线; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 楷体; mso-hansi-font-family: 等线; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi; mso-font-kerning: 1.0pt }
h1 { mso-style-update: auto; mso-style-priority: 9; mso-style-unhide: no; mso-style-qformat: yes; mso-style-link: “标题 1 字符”; mso-style-next: 正文; margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; line-height: 30pt; mso-line-height-rule: exactly; mso-pagination: lines-together; page-break-after: avoid; mso-outline-level: 1; font-size: 16pt; mso-bidi-font-size: 22.0pt; font-family: 等线; mso-ascii-font-family: 等线; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 黑体; mso-hansi-font-family: 等线; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi; mso-font-kerning: 22.0pt; font-weight: bold }
h2 { mso-style-update: auto; mso-style-priority: 9; mso-style-qformat: yes; mso-style-parent: “普通\(网站\)”; mso-style-link: “标题 2 字符”; mso-style-next: 正文; margin: 0 0 0.0001pt; text-align: left; line-height: 30pt; mso-line-height-rule: exactly; mso-pagination: lines-together; page-break-after: avoid; mso-outline-level: 2; font-size: 16pt; mso-bidi-font-size: 12.0pt; font-family: 楷体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; font-weight: bold; mso-bidi-font-weight: normal }
h3 { mso-style-update: auto; mso-style-priority: 9; mso-style-qformat: yes; mso-style-link: “标题 3 字符”; mso-style-next: 正文; margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; line-height: 30pt; mso-line-height-rule: exactly; mso-pagination: lines-together; page-break-after: avoid; mso-outline-level: 3; font-size: 14pt; mso-bidi-font-size: 16.0pt; font-family: 等线; mso-ascii-font-family: 等线; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 楷体; mso-hansi-font-family: 等线; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi; mso-font-kerning: 1.0pt; font-weight: bold }
h4 { mso-style-update: auto; mso-style-noshow: yes; mso-style-priority: 9; mso-style-qformat: yes; mso-style-link: “标题 4 字符”; mso-style-next: 正文; margin: 14pt 0 14.5pt; text-align: justify; text-justify: inter-ideograph; line-height: 156%; mso-pagination: lines-together; page-break-after: avoid; mso-outline-level: 4; font-size: 14pt; font-family: “等线 Light”; mso-ascii-font-family: “等线 Light”; mso-ascii-theme-font: major-latin; mso-fareast-font-family: “等线 Light”; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: “等线 Light”; mso-hansi-theme-font: major-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: major-bidi; mso-font-kerning: 1.0pt; font-weight: bold }
p.MsoHeader, li.MsoHeader, div.MsoHeader { mso-style-priority: 99; mso-style-link: “页眉 字符”; margin: 0 0 0.0001pt; text-align: center; mso-pagination: none; tab-stops: center 207.65pt right 415.3pt; layout-grid-mode: char; border: none; mso-border-bottom-alt: solid windowtext .75pt; padding: 0; mso-padding-alt: 0cm 0cm 1.0pt 0cm; font-size: 9pt; font-family: 等线; mso-ascii-font-family: 等线; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 楷体; mso-hansi-font-family: 等线; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi; mso-font-kerning: 1.0pt }
p.MsoFooter, li.MsoFooter, div.MsoFooter { mso-style-priority: 99; mso-style-link: “页脚 字符”; margin: 0 0 0.0001pt; text-align: left; mso-pagination: none; tab-stops: center 207.65pt right 415.3pt; layout-grid-mode: char; font-size: 9pt; font-family: 等线; mso-ascii-font-family: 等线; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 楷体; mso-hansi-font-family: 等线; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi; mso-font-kerning: 1.0pt }
p.MsoTitle, li.MsoTitle, div.MsoTitle { mso-style-update: auto; mso-style-priority: 10; mso-style-unhide: no; mso-style-qformat: yes; mso-style-link: “标题 字符”; mso-style-next: 正文; margin: 12pt 0 3pt; text-align: center; mso-pagination: none; mso-outline-level: 1; font-size: 16pt; font-family: “等线 Light”; mso-ascii-font-family: “等线 Light”; mso-ascii-theme-font: major-latin; mso-fareast-font-family: “等线 Light”; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: “等线 Light”; mso-hansi-theme-font: major-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: major-bidi; mso-font-kerning: 1.0pt; font-weight: bold }
p.MsoSubtitle, li.MsoSubtitle, div.MsoSubtitle { mso-style-update: auto; mso-style-priority: 11; mso-style-unhide: no; mso-style-qformat: yes; mso-style-link: “副标题 字符”; mso-style-next: 正文; margin: 12pt 0 3pt; text-align: center; line-height: 130%; mso-pagination: none; mso-outline-level: 2; font-size: 16pt; font-family: 等线; mso-ascii-font-family: 等线; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 楷体; mso-hansi-font-family: 等线; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi; mso-font-kerning: 14.0pt; font-weight: bold }
p { mso-style-noshow: yes; mso-style-priority: 99; margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; mso-pagination: none; font-size: 12pt; font-family: “Times New Roman”, serif; mso-fareast-font-family: 楷体; mso-font-kerning: 1.0pt }
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph { mso-style-priority: 34; mso-style-unhide: no; mso-style-qformat: yes; margin: 0 0 0.0001pt; text-align: justify; text-justify: inter-ideograph; text-indent: 21pt; mso-char-indent-count: 2.0; mso-pagination: none; font-size: 14pt; mso-bidi-font-size: 11.0pt; font-family: 等线; mso-ascii-font-family: 等线; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 楷体; mso-hansi-font-family: 等线; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi; mso-font-kerning: 1.0pt }
{ mso-style-name: “标题 1 字符”; mso-style-priority: 9; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: “标题 1”; mso-ansi-font-size: 16.0pt; mso-bidi-font-size: 22.0pt; font-family: 黑体; mso-fareast-font-family: 黑体; mso-font-kerning: 22.0pt; font-weight: bold }
{ mso-style-name: “标题 2 字符”; mso-style-priority: 9; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: “标题 2”; mso-ansi-font-size: 16.0pt; mso-bidi-font-size: 12.0pt; font-family: 楷体; mso-ascii-font-family: 楷体; mso-fareast-font-family: 楷体; mso-hansi-font-family: 楷体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; font-weight: bold; mso-bidi-font-weight: normal }
{ mso-style-name: “标题 3 字符”; mso-style-priority: 9; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: “标题 3”; mso-ansi-font-size: 14.0pt; mso-bidi-font-size: 16.0pt; font-family: 楷体; mso-fareast-font-family: 楷体; font-weight: bold }
{ mso-style-name: “标题 4 字符”; mso-style-noshow: yes; mso-style-priority: 9; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: “标题 4”; mso-ansi-font-size: 14.0pt; mso-bidi-font-size: 14.0pt; font-family: “等线 Light”; mso-ascii-font-family: “等线 Light”; mso-ascii-theme-font: major-latin; mso-fareast-font-family: “等线 Light”; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: “等线 Light”; mso-hansi-theme-font: major-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: major-bidi; font-weight: bold }
span.a { mso-style-name: “标题 字符”; mso-style-priority: 10; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: 标题; mso-ansi-font-size: 16.0pt; mso-bidi-font-size: 16.0pt; font-family: “等线 Light”; mso-ascii-font-family: “等线 Light”; mso-ascii-theme-font: major-latin; mso-fareast-font-family: “等线 Light”; mso-fareast-theme-font: major-fareast; mso-hansi-font-family: “等线 Light”; mso-hansi-theme-font: major-latin; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: major-bidi; font-weight: bold }
span.a0 { mso-style-name: “副标题 字符”; mso-style-priority: 11; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: 副标题; mso-ansi-font-size: 16.0pt; mso-bidi-font-size: 16.0pt; mso-font-kerning: 14.0pt; font-weight: bold }
span.a1 { mso-style-name: “页眉 字符”; mso-style-priority: 99; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: 页眉; mso-ansi-font-size: 9.0pt; mso-bidi-font-size: 9.0pt; font-family: 楷体; mso-fareast-font-family: 楷体 }
span.a2 { mso-style-name: “页脚 字符”; mso-style-priority: 99; mso-style-unhide: no; mso-style-locked: yes; mso-style-link: 页脚; mso-ansi-font-size: 9.0pt; mso-bidi-font-size: 9.0pt; font-family: 楷体; mso-fareast-font-family: 楷体 }
.MsoChpDefault { mso-style-type: export-only; mso-default-props: yes; font-family: 等线; mso-bidi-font-family: “Times New Roman”; mso-bidi-theme-font: minor-bidi }
@page { mso-page-border-surround-header: no mso-page-border-surround-footer: no mso-footnote-separator: url(“实验:模拟实现主机跨路由通信.files/header.htm”) fs mso-footnote-continuation-separator: url(“实验:模拟实现主机跨路由通信.files/header.htm”) fcs mso-endnote-separator: url(“实验:模拟实现主机跨路由通信.files/header.htm”) es mso-endnote-continuation-separator: url(“实验:模拟实现主机跨路由通信.files/header.htm”) ecs }
@page WordSection1 { size: 595.3pt 841.9pt margin-top: 72pt margin-right: 90pt margin-bottom: 72pt margin-left: 90pt mso-header-margin: 42.55pt mso-footer-margin: 49.6pt mso-paper-source: 0 layout-grid: 15.6pt }
div.WordSection1 { page: WordSection1 }

实验目的:

通过虚拟机模拟路由器,实现两台主机之间跨路由通信。

实验器材:

5个虚拟机,其中2个作为主机使用,3个模拟路由器使用。

本实验中所用虚拟机均为centos6

实验步骤:

1、画出构图,部署所需要的网络环境。

 

如图所示,R1R2R3为模拟的路由器,AB为两个主机。配置IP也在图中有所说明。

2、根据构图,配置5个虚拟机的设置。

图中可以看出,我们一共需要四个网段,我们可以在虚拟机中添加新的网段,具体步骤如图:

至此,我们的网段添加完毕。

接着我们对虚拟机的网段进行设置:

我们把虚拟机进行重命名以确保我们能够清楚的分辨每台虚拟机的作用:

接着,我们以主机A的网段设置为例,来演示一下如何更改:

同理,对剩下四个虚拟机做相同操作,作为主机的两台虚拟机只需要设置一个网段,而作为路由器的三台虚拟机则需要设置两个网段,具体设置如下:

    centos6.9-A eth1:VMnet11

    node1 eth0:VMnet11

          eth1:VMnet12

    node2 eth0:VMnet12

          eth1:VMnet13

   node3 eth0:VMnet13

          eth1:VMnet14

    centos6.9-B eth0:VMnet14

全部设置完毕后,开启所有虚拟机。

3、给用于通信的两个主机添加相对应的IP和网关。

首先是centos6.9-Aeth1。我们直接修改配置文件 /etc/sysconfig/network-scripts/ifcfg-eth1。添加我们规划的IP,子网掩码和网关。

设置完毕后,我们来重启一下网络服务

图中提示错误,是因为找不到eth0这个网卡,而在本实验中,我本来就没有设置该网卡,所以可以忽视掉。

接下来我们用“route -n”看一下这个设置有没有生效

很显然,我们的设置已经生效。

至此,我们已经完成第一个通信主机的设置,接下来,我们来配置第二个通信主机:

同样的,我们直接修改配置文件 /etc/sysconfig/network-scripts/ifcfg-eth1。添加我们规划的IP,子网掩码和网关。

重启服务,并查看是否成功:

至此,我们的两台通信主机已经设置完毕。

4、进行三个路由的IP和路由表的配置。

Node1

至此,网络IP已经配置完成。接下来,我们要来配置路由表,为了保证我们的两台主机可以连通,我们需要添加如下信息:

网络ID

子网掩码

接口

网关

10.1.0.0

255.255.0.0

eth0

 

10.2.0.0

255.255.0.0

eth1

 

10.3.0.0

255.255.0.0

eth1

10.2.0.201

10.4.0.0

255.255.0.0

eth1

10.2.0.201

我们使用“route -n”命令查看现有的路由表

图中发现,表中数据已经有两个存在。所以我们只需要添加另外两个进路由表就可以啦~所以我们来加吧!

至此,我们第一个路由器的配置就全部完成,接着,我们用相同的方法给剩下两个路由器做配置。方法相同~所以下面就只列出剩下两个路由器的路由表啦:

Node2

网络ID

子网掩码

接口

网关

10.1.0.0

255.255.0.0

eth0

10.2.0.200

10.2.0.0

255.255.0.0

Eth0

 

10.3.0.0

255.255.0.0

eth1

 

10.4.0.0

255.255.0.0

eth1

10.3.0.201

 

Node3

网络ID

子网掩码

接口

网关

10.1.0.0

255.255.0.0

eth0

10.3.0.200

10.2.0.0

255.255.0.0

eth0

10.3.0.200

10.3.0.0

255.255.0.0

eth0

 

10.4.0.0

255.255.0.0

eth1

 

全部设置完毕后,我们可以先试一下在相邻的两个虚拟机之间ping,如下图:

 

在上面的几个图中我们可以看出,我们的相邻虚拟机已经可以两两ping通,那么,这是不是意味着我们的实验完成了呢?接下来我们来试一试node2ping主机A

咦?为什么ping不通?这就很尴尬了,我们来找找原因。

奥,原来是因为我们是把node1当做路由器,但是事实是他还是一个主机,它接收到来自node2的包发现不是自己的就扔掉了,而不会转给主机A,所以,接下来我们就要把node1node2node3三个路由器设置成可以转发的。具体操作如下:

echo 1 > /proc/sys/net/ipv4/ip_forward

我们在node1中输入上面的命令,然后再用node2ping 主机A

当当当当~已经可以ping通了~

接下来我们要在剩下的两个充当路由器的虚拟机中也输入上述命令:

好了,接下来就是见证奇迹的时刻!我们用主机Bping主机A

啊咧,为啥还是ping不通呢?

让我们来查一下防火墙

奥,原来是因为防火墙没有关闭,好吧,我们把5台虚拟机的防火墙都临时关闭。命令是:“iptables -F”

全部关闭以后,我们再来试着ping一下~

当当当当,已经可以啦~

现在我们也可以用mtr来动态跟踪路由状态~

看,三个路由器的端口IP都有喏,当然,也少不了我们主机B的啦。

完成了!撒花✿✿(°▽°)

以上,我们的实验圆满成功!

当然啦,既然我们做实验,就要做得完美一点嘛~我们可以把实验的过程进行优化呀~

我们可以看到,在路由器R3(node3)的路由表记录中,有两条记录是基本一致的:

那么,我们可以把这两条记录合并成一条吗?如同下表中所示:

网络ID

子网掩码

接口

网关

0.0.0.0

255.255.0.0

eth0

10.3.0.200

接着我们就来试试看:

首先,我们把这两条记录从路由表中删除,然后,我们在添加新的记录:

然后,我们用主机Aping一下主机B,看看效果如何:

依然是可以ping通的。那么,这是为什么呢?这个是由于我们的R3是边缘路由,我们完全可以把它配置成为默认路由,只负责转发就好啦~同理,R1也可以进行这样的设置。

接下来我们来试一试另外一种操作,如果我们只给R1的路由表中添加10.4.0.0网段的路由信息,而不添加10.3.0.0网段的路由信息,那么,我们的消息可以到达10.4.0.0网段吗?我们来实验一下:

R1路由表中的10.3.0.0网段的路由信息删掉:

删掉了以后,我们再用主机Aping一下主机B,看看结果如何:

还是可以ping通的吖~这是为什么呢?

我们先来动态跟踪一下路由信息:

咦,有没有发现,我们的第三个是???状态,这是因为我们的R1一头连着主机A,一头连着外面,当数据发送到R1时,R1直接负责转发就可以了,通过R1到达R2,然后从R2继续向下一个路由器转发,也就是我们的R3,最终通过R3到达我们的目的网段。由于在R1中没有配置10.3.0.0的网段信息,所以我们的路由跟踪是读不出来R3IP的。当然,如果这个实验的目的网段为10.3.0.0,就不能实现啦!

 

至此,我们的实验已经全部结束0.0

版权声明:本文为keerya原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/keerya/p/7488036.html