|
|
|
|
|
本实验为交换与路由的综合实验,完成本实验,目的是为了掌握子网的划分、配置VLAN,以及在路由器上配置单臂路由来实现VLAN之间的路由;并且掌握在有子网的情况下使用静态路由协议实现子网的互通。 |
所需实验设备 |
1)3台路由器 2)2台交换机 3)2根交叉线 4)2根直连线 |
实验描述 |
1、划分子网 在192.168.1.0/25网段上包含3个VLAN,其中,VLAN 2中包含50台主机,VLAN 3和4中各包含25台主机;请写出子网划分的方案; 2、配置VLAN与单臂路由 1)在交换机上配置静态路由) 在路由器上配置单臂路由,实现交换机上各VLAN的互通; 3、配置RIP路由协议 在3台路由器上配置RIP路由协议,实现两台交换机上连接的各网段的互通。 4.交换机的转发原理 如果同在一个VLAN中的两台主机互相ping通后,是否还能不同vlan间ping通?为什么? |
提交作业 |
1) 路由器与交换机的配置文件 2) 实验报告 |
子网划分:
因为2的2次方是4,所以192.168.1.0/25再借一位就可以了。子网掩码为255.255.255.192
Vlan2网络地址:192.168.1.0 可用IP:192.168.1.1―192.168.1.62 广播地址:192.168.1.63
Vlan3、vlan4网络地址:192.168.1.64 可用IP:192.168.1.65―192.168.1.126 广播地址:192.168.1.127
Vlan2网络地址:192.168.1.128 可用IP:192.168.1.129―192.168.1.190 广播地址:192.168.1.191
Vlan3、vlan4网络地址:192.168.1.192 可用IP:192.168.1.193―192.168.1.254 广播地址:192.168.1.255
静态试验一:
基本思路:
(一)对于路由器:
1:命名
2:设置端口IP和激活相应端口
3:配置单臂路由(对于R1和R3)
4:配置静态路由
(二)对于交换机:
1:命名
2:添加vlan
3:将指定端口添加到指定vlan
4:将相应端口设置成trunk模式
(三)对于PC(这里把router当做PC):
1:命名
2:设置IP
(四)查看命名:
查看基本配置:
show running-config
查看vlan信息:
show vlan-switchport
查看端口信息:
show interface 端口号
查看路由信息:
show ip route
--------------------------------------------------
配置文档:
R1:
enable
config terminal
no ip domain-lookup //禁止DNS服务
hostname R1
interface f0/0
no shutdown
interface f1/0
ip address 10.10.1.1 255.255.255.0 //设置IP
no shutdown
interface f0/0.2 //设置子端口信息
encapsulation dot1q 2
ip address 192.168.1.1 255.255.255.192
exit
interface f0/0.3 //设置子端口信息
encapsulation dot1q 3
ip address 192.168.1.65 255.255.255.192
no shutdown
exit
ip route 10.20.1.0 255.255.255.0 10.10.1.2 //设置静态路由
ip route 192.168.1.128 255.255.255.128 10.10.1.2 //设置静态路由
end
write
------------------------------------------------------
R2:
enable
config terminal
no ip domain-lookup //禁止DNS服务
hostname R2
interface f0/0
ip address 10.10.1.2 255.255.255.0 //设置IP
no shutdown
interface f1/0
ip address 10.20.1.1 255.255.255.0 //设置IP
no shutdown
ip route 192.168.1.0 255.255.255.128 10.10.1.1 //设置静态路由
ip route 192.168.1.128 255.255.255.128 10.20.1.2 //设置静态路由
end
write
-----------------------------------------------------------
R3:
enable
config terminal
no ip domain-lookup //禁止DNS服务
hostname R3
interface f1/0
no shutdown
interface f0/0
ip address 10.20.1.2 255.255.255.0 //设置IP
no shutdown
interface f1/0.2 //设置子端口信息
encapsulation dot1q 2
ip address 192.168.1.129 255.255.255.192
exit
interface f1/0.3 //设置子端口信息
encapsulation dot1q 3
ip address 192.168.1.193 255.255.255.192
exit
ip route 10.10.1.0 255.255.255.0 10.20.1.1 //设置静态路由
ip route 192.168.1.0 255.255.255.128 10.20.1.1 //设置静态路由
end
write
-------------------------------------------------------
sw1:
enable
config terminal
hostname sw1
exit
vlan database //添加vlan
vlan 2
vlan 3
exit
config terminal
interface f0/0
switchport mode trunk //将指定端口设置成trunk
interface f0/2
switchport access vlan 2 //将指定端口添加到指定vlan
interface f0/3
switchport access vlan 3 //将指定端口添加到指定vlan
end
write
---------------------------------------------------------------
sw2:
enable
config terminal
hostname sw2
exit
vlan database //添加vlan
vlan 2
vlan 3
exit
config terminal
interface f0/0
switchport mode trunk //将指定端口设置成trunk
interface f0/2
switchport access vlan 2 //将指定端口添加到指定vlan
interface f0/3
switchport access vlan 3 //将指定端口添加到指定vlan
end
write
------------------------------------------------------------
pc1:
enable
config terminal
no ip routing
hostname pc1
interface f0/0
ip address 192.168.1.20 255.255.255.192 //设置IP
no shutdown
end
write
------------------------------------------------------------
pc2:
enable
config terminal
no ip routing
hostname pc2
interface f0/0
ip address 192.168.1.68 255.255.255.192 //设置IP
no shutdown
end
write
------------------------------------------------------------
pc3:
enable
config terminal
no ip routing
hostname pc3
interface f0/0
ip address 192.168.1.168 255.255.255.192 //设置IP
no shutdown
end
write
------------------------------------------------------------
pc4:
enable
config terminal
no ip routing
hostname pc4
interface f0/0
ip address 192.168.1.200 255.255.255.192 //设置IP
no shutdown
end
write
调试图片:
静态路由实验2:
基本思路:
(一)对于路由器:
1:命名
2:设置端口IP和激活相应端口
3:配置单臂路由(对于R1和R3)
4:配置静态路由
(二)对于交换机:
1:命名
2:添加vlan
3:将指定端口添加到指定vlan
4:将相应端口设置成trunk模式
(三)对于PC(这里把router当做PC):
1:命名
2:设置IP
(四)查看命名:
查看基本配置:
show running-config
查看vlan信息:
show vlan-switchport
查看端口信息:
show interface 端口号
查看路由信息:
show ip route
--------------------------------------------------
配置文档:
R1:
enable
config terminal
no ip domain-lookup
hostname R1
interface f0/0
no shutdown
interface f1/0
ip address 10.10.1.1 255.255.255.0
no shutdown
interface f0/0.2
encapsulation dot1q 2
ip address 192.168.1.1 255.255.255.192
exit
interface f0/0.3
encapsulation dot1q 3
ip address 192.168.1.65 255.255.255.192
no shutdown
exit
ip route 10.20.1.0 255.255.255.0 10.10.1.2
ip route 192.168.1.128 255.255.255.192 10.10.1.2
ip route 192.168.1.192 255.255.255.192 10.10.1.2
end
write
------------------------------------------------------
R2:
enable
config terminal
no ip domain-lookup
hostname R2
interface f0/0
ip address 10.10.1.2 255.255.255.0
no shutdown
interface f1/0
ip address 10.20.1.1 255.255.255.0
no shutdown
ip route 192.168.1.0 255.255.255.192 10.10.1.1
ip route 192.168.1.64 255.255.255.192 10.10.1.1
ip route 192.168.1.128 255.255.255.192 10.20.1.2
ip route 192.168.1.192 255.255.255.192 10.20.1.2
end
write
-----------------------------------------------------------
R3:
enable
config terminal
no ip domain-lookup
hostname R3
interface f1/0
no shutdown
interface f0/0
ip address 10.20.1.2 255.255.255.0
no shutdown
interface f1/0.2
encapsulation dot1q 2
ip address 192.168.1.129 255.255.255.192
exit
interface f1/0.3
encapsulation dot1q 3
ip address 192.168.1.193 255.255.255.192
exit
ip route 10.10.1.0 255.255.255.0 10.20.1.1
ip route 192.168.1.0 255.255.255.192 10.20.1.1
ip route 192.168.1.64 255.255.255.192 10.20.1.1
end
write
-------------------------------------------------------
sw1:
enable
config terminal
hostname sw1
exit
vlan database
vlan 2
vlan 3
exit
config terminal
interface f0/0
switchport mode trunk
interface f0/2
switchport access vlan 2
interface f0/3
switchport access vlan 3
end
write
---------------------------------------------------------------
sw2:
enable
config terminal
hostname sw2
exit
vlan database
vlan 2
vlan 3
exit
config terminal
interface f0/0
switchport mode trunk
interface f0/2
switchport access vlan 2
interface f0/3
switchport access vlan 3
end
write
------------------------------------------------------------
pc1:
enable
config terminal
no ip routing
hostname pc1
interface f0/0
ip address 192.168.1.20 255.255.255.192
no shutdown
end
write
------------------------------------------------------------
pc2:
enable
config terminal
no ip routing
hostname pc2
interface f0/0
ip address 192.168.1.68 255.255.255.192
no shutdown
end
write
------------------------------------------------------------
pc3:
enable
config terminal
no ip routing
hostname pc3
interface f0/0
ip address 192.168.1.168 255.255.255.192
no shutdown
end
write
------------------------------------------------------------
pc4:
enable
config terminal
no ip routing
hostname pc4
interface f0/0
ip address 192.168.1.200 255.255.255.192
no shutdown
end
write
调试图片:
备注:对于上面两种方式设置静态路由,虽然都能够P通,但是发现一个问题就是第二种方法设置静态路由时候比较麻烦点,而且考虑到vlan的问题…相对来说,第一种方式更加简便,而且容易实现…..