01

实验十  交换机和路由器组合实验

    要求所有计算机和交换机以及路由器的端口可以联通。由于交换机下的计算机在两个网络段,所以要求划分vlan,现要求switchA和switchB的f0/5和f0/6在vlan 2.

    1. 设置计算机的IP地址和网关:
[root#PCA root]# ifconfig eth0 10.65.1.1 netmask 255.255.0.0
[root#PCB root]# ifconfig eth0 10.66.1.1 netmask 255.255.0.0
[root#PCC root]# ifconfig eth0 10.69.1.1 netmask 255.255.0.0
[root#PCD root]# ifconfig eth0 10.70.1.1 netmask 255.255.0.0
[root#PCE root]# ifconfig eth0 10.60.1.1 netmask 255.255.0.0
[root#PCF root]# ifconfig eth0 10.66.1.3 netmask 255.255.0.0
[root#PCG root]# ifconfig eth0 10.60.1.3 netmask 255.255.0.0
[root#PCA root]# route add default gw 10.65.1.2
[root#PCB root]# route add default gw 10.66.1.2
[root#PCC root]# route add default gw 10.69.1.2
[root#PCD root]# route add default gw 10.70.1.2
[root#PCE root]# route add default gw 10.60.1.2
[root#PCF root]# route add default gw 10.66.1.2
[root#PCG root]# route add default gw 10.60.1.2

    2. 设置交换机的IP地址、网关和干线
switchA#vlan database
switchA(vlan)#vlan 2
switchA(vlan)#exit
switchA#conf t
switchA(config)#int f0/5
switchA(config-if)#switchport access vlan 2
switchA(config-if)#no shutdown
switchA(config-if)#int f0/6
switchA(config-if)#switchport access vlan 2
switchA(config-if)#no shutdown
switchA(config-if)#int f0/1
switchA(config-if)#switchport mode trunk
switchA(config-if)#switchport trunk encap dot1q
switchA(config-if)#no shutdown
switchA(config-if)#end
switchA#sh vlan
switchA#sh run

switchB#vlan database
switchB(vlan)#vlan 2
switchB(vlan)#exit
switchB#conf t
switchB(config)#int f0/5
switchB(config-if)#switchport access vlan 2
switchB(config-if)#no shutdown
switchB(config-if)#int f0/6
switchB(config-if)#switchport access vlan 2
switchB(config-if)#no shutdown
switchB(config-if)#int f0/8
switchB(config-if)#switchport mode trunk
switchB(config-if)#switchport trunk encap dot1q
switchB(config-if)#no shutdown
switchB(config-if)#int f0/2
switchB(config-if)#switchport mode trunk
switchB(config-if)#switchport trunk encap dot1q
switchB(config-if)#no shutdown
switchB(config-if)#end
switchB#sh vlan
switchB#sh run

switchA#conf t
switchA(config)#int vlan 1
switchA(config-if)#ip address 10.66.1.8 255.255.0.0
switchA(config-if)#exit
switchA(config)#ip default-gateway 10.66.1.2
switchA(config)#end
switchA#sh run

switchB#conf t
switchB(config)#int vlan 1
switchB(config-if)#ip address 10.66.1.9 255.255.0.0
switchB(config-if)#exit
switchB(config)#ip default-gateway 10.66.1.2
switchB(config)#end
switchB#sh run

    3.设置路由器的IP和动态路由
RouterA(config)int f0/0
RouterA(config-if)#ip address 10.65.1.2 255.255.0.0
RouterA(config-if)#no shutdown
RouterA(config-if)#int f0/1
RouterA(config-if)#no shutdown
RouterA(config-if)#int f0/1.1
RouterA(config-subif.1)#encapsulation dot1q 1
RouterA(config-subif)#ip address 10.66.1.2 255.255.0.0
RouterA(config-subif)#int f0/1.2
RouterA(config-subif.2)#encapsulation dot1q 2
RouterA(config-subif)#ip address 10.60.1.2 255.255.0.0
RouterA(config-subif)#int s0/1
RouterA(config-if)#ip address 10.68.1.2 255.255.0.0
RouterA(config-if)#no shutdown
RouterA(config-if)#exit
RouterA(config)#ip routing
RouterA(config)#router rip
RouterA(config-router)#network 10.0.0.0
RouterA(config-router)#end
RouterA#

RouterC和RouterB的IP如下,设置过程略。
RouterC s0/0 :10.68.1.1  s0/1:10.78.1.2
RouterB s0/0 :10.78.1.1  f0/0 :10.69.1.2  f0/1:10.70.1.2

4.测试各点的联通性
[root@PCA root]#ping 10.65.1.2 (通)
[root@PCA root]#ping 10.66.1.1 (通)
[root@PCA root]#ping 10.66.1.2 (通)
[root@PCA root]#ping 10.66.1.3 (通)
[root@PCA root]#ping 10.60.1.2 (通)
--------------------------------------------------------
[root@PCA root]#ping 10.60.1.1 (不通)
[root@PCA root]#ping 10.60.1.3 (不通)
//不知道为什么,只要是VLAN2下的终端就不通!!!???我感觉应该是VLAN没有设好!!!
--------------------------------------------------------

[root@PCA root]#ping 10.69.1.1 (通)
[root@PCA root]#ping 10.69.1.2 (通)
[root@PCA root]#ping 10.70.1.1 (通)
[root@PCA root]#ping 10.70.1.2 (通)

[root@PCA root]#ping 10.66.1.8 (通)
[root@PCA root]#ping 10.66.1.9 (通)

switchA#ping 10.65.1.1 (通)
switchA#ping 10.66.1.1 (通)
switchA#ping 10.66.1.2 (通)
switchA#ping 10.66.1.3 (通)
switchA#ping 10.60.1.1 (通)
switchA#ping 10.60.1.2 (通)
switchA#ping 10.60.1.3 (通)

switchA#ping 10.69.1.1 (通)
switchA#ping 10.70.1.1 (通)

[root@PCD root]#ping 10.66.1.9 (通)

    network是发布路由,现将routerC的f0/0设置为11.0.0.0网络,情况如何呢?

RouterC(config)#int f0/0
RouterC(config-if)#ip address 11.0.0.2 255.255.0.0
RouterC(config-if)#no shutdown
[root#PCH root]# ifconfig eth0 11.0.0.1 netmask 255.255.0.0
[root#PCH root]# route add default gw 11.0.0.2

    现在PCH可以与其它计算机互通吗?(不发布11网络,别人看不到,但它可以看到别人,所以单向通)。
设置RouterC的network all或增加network 11.0.0.0 情况以如何呢?(互通了)。