乾颐堂 发表于 2023-9-6 15:30:39

理解二层转发及网关的作用

https://editor-material.365editor.com/style/20230220167686474063f2ece47a929material.gif

1、完成两个网段内的主机之间互通;理解二层转发及网关的作用;

https://editor-user.365editor.com/98/85/4933185/1693982760533222.png

1.设置pc1-pc2的IP地址:为二层内的pc通讯使用

2.设置pc1至pc4之间的网关地址:为不同网段之间通讯转发

https://editor-user.365editor.com/98/85/4933185/1693982785478869.png

3.使用pc1ping-pc3后抓包得知

https://editor-user.365editor.com/98/85/4933185/1693982800778842.pnghttps://editor-user.365editor.com/98/85/4933185/1693982808524935.png
ping包发出到二层交换机时发现不是同一网段并发送arp请求包给网关192.168.1.254

网关收到后并回复其g0/0/0的mac地址

4.

https://editor-user.365editor.com/98/85/4933185/1693982852302174.png
https://editor-user.365editor.com/98/85/4933185/1693982858123992.png
https://editor-user.365editor.com/98/85/4933185/1693982865989025.png

pc1收到回复再次发送icmp协议ping请求包,mac地址为g0/0/0口,目地IP地址为2.1

5.

https://editor-user.365editor.com/98/85/4933185/1693982891160661.png

2.0网段发送该网段的arp广播

2.1收到广播确认回复其mac地址并收到该网段g0/0/1口的mac地址

此时三层路由器形成路由表

https://editor-user.365editor.com/98/85/4933185/1693982914598854.png

目的网段为192.168.1的吓一跳为1.254口,目的网段为2.1的下一跳出口为2.254口

至此对接成功,pc1发送数据包到二层交换机解析mac地址为g0/0/0转发至三层网关。解析路由表目的地址为2.0网段的出口为2.254,并重新封装源目mac进行转发。pc3回复同上。

二.原C类地址192.168.10.0/24,向主机位借2位,分别写了网络号、新掩码、广播地址及容纳的主机数;

网络地址:192.168.10.0/26    192.168.10.64/26192.168.10.128/26192.168.10.192/26

新掩码:255.255.255.192

广播地址:192.168.10.63/26   192.168.10.127/26    192.168.10.191/26         
192.168.10.255/26

主机数:2^6*4-8

https://editor-material.365editor.com/style/20230220167686474063f2ece49a3d3material.gifhttps://editor-material.365editor.com/style/20230220167686474063f2ece4b7c43material.gif

页: [1]
查看完整版本: 理解二层转发及网关的作用